for i in(Solved)

About writing shell scripts and making the most of your shell
Forum rules
Topics in this forum are automatically closed 6 months after creation.
Locked
viking777

for i in(Solved)

Post by viking777 »

What on earth does it mean!!!!

I guess it is like one of these secret things "I could tell you but I would have to kill you" , like asking Barak Obama what the code is for the nuclear launch triggers, except even more heavily protected!

I am pretty good at google searching, I can even interpret 'man' pages sometimes (not often I grant you), but never have I found any explanation of this secret code.

If you insist that only 12 years of Linux usage is not enough to be granted access to this privileged piece of information then I guess I will have to carry on without it, but if you feel like becoming a 'whistle blower' and can actually impart its meaning to me I would definitely like to know. I don't suppose it will change my life, but it does bug me that every time I see it in some script somewhere I don't have a clue what is means and seem unable to find out.
Last edited by LockBot on Wed Dec 28, 2022 7:16 am, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
rhlegion

for i in

Post by rhlegion »

GeneC

Re: for i in

Post by GeneC »

viking777 wrote:...........I guess it is like one of these secret things "I could tell you but I would have to kill you" , like asking Barak Obama what the code is for the nuclear launch triggers, except even more heavily protected!.........
Viking

I just googled the nuclear lauch code.
Its

Code: Select all

gjpewput9tu89tjgp298tug2t590y-5yu2]=kigwtkjptru9-y35hi0yt24
Dont tell anybody... :lol:
by zerozero on Thu Aug 09, 2012 1:51 pm

if you could read portuguese and i could understand what's written there
Meu português não é muito bom esses dias.... :D
zerozero

Re: for i in

Post by zerozero »

GeneC wrote: Meu português não é muito bom esses dias.... :D
Image
viking777

Re: for i in

Post by viking777 »

Code: Select all

I just googled the nuclear lauch code.
Its

CODE: SELECT ALL
gjpewput9tu89tjgp298tug2t590y-5yu2]=kigwtkjptru9-y35hi0yt24
Ah! Thanks Gene, I was typing 23 at the end.

You have all got 15 minutes left to live :twisted: :twisted:
Habitual

Re: for i in

Post by Habitual »

Am I to take this subject seriously/literally?

"This loop allows for specification of a list of values. A list of commands is executed for each value in the list."
The for loop is a little bit different from other programming languages. Basically, it let's you iterate over a series of 'words' within a string.
short and simple example:

Code: Select all

for i in cat dog parrot ; do echo $i ; done
The "i" in "for i" becomes $i which in this case holds 1 record each for "cat dog parrot"

the "for i" could very well be "anything" (with reservations, NOTE you armchair forum quarterbacks)

Code: Select all

for animal in cat dog parrot ; do echo $animal ; done
for fruit in apples pears bananas ; do echo $fruit ; done
Surely, you can see the relationship now?

HTH.
BrianD

Re: for i in

Post by BrianD »

"for i in" is part of a programming phrase that expects a set list to follow, followed by ("do" and ) an execution block. each set member is iteratively assigned to the temporary variable i, then the execution block is performed (wherein, typically, the value assigned to i is used in some fashion).

for i in (*.jpg) do jpgresize %i

in the above pseudo-code statement, we're using the filesystem to return a list of filenames matching the (*.jpg) filespec. for each filename in the resulting list, it will run the (completely made-up by me) program 'jpgresize' and pass the filename from the list as a parameter to that program.
Habitual

Re: for i in

Post by Habitual »

BrianD wrote:...the (completely made-up by me) program 'jpgresize' ...
ya know I had to... :twisted:
Co-inky Dink?
rhlegion

Re: for i in

Post by rhlegion »

wah?? the page was in perfect english when i load it?????
viking777

Re: for i in

Post by viking777 »

I assure you the thread was meant to be serious (although it did go a bit 'off topic' at one stage :lol: ), I have seen this phrase in scripts all over the place and could NEVER find an explanation of what it meant written anywhere, but with the help of the answers here I am a little wiser.

You may have guessed - I don't really do scripting (and certainly don't do coding).

Thanks to all.
Habitual

Re: for i in(Solved)

Post by Habitual »

I assumed a Level 11 would know what a "for i" loop construct was all about.

I guess that's my Bad.
viking777

Re: for i in(Solved)

Post by viking777 »

Oh definitely your mistake Habitual.

If I had posted "Welcome to the Mint Forums" to 3500 newly joined members I would still be at level 11. So it doesn't mean much does it?
Locked

Return to “Scripts & Bash”