TheBonsai 1195407736 learn http://bash-hackers.org/wiki/doku.php?id=syntax:ccmd:classic_for lhunath 1203497433 forget lhunath 1203497553 learn for var in $something -- For is a bash construct that iterates over words. In this example, the content of 'something' is split up into words removing all whitespace. For then puts each of those "words" into 'var', one at a time. DO NOT USE 'for' FOR READING SOMETHING THAT IS LINE-BASED! lhunath 1203497671 forget lhunath 1203497748 learn for var in $(something) -- 'for' is a bash construct that iterates over words. In this example, the result of the command 'something' is split up into words removing all whitespace. 'for' then puts each of those "words" into 'var', one at a time. 'for' should NOT be used for reading something that is line-based! See http://bash-hackers.org/wiki/doku.php?id=syntax:ccmd:classic_for lhunath 1203497777 forget lhunath 1203497848 learn for var in $(something) -- 'for' is a bash construct that iterates over words. The output of the command 'something' is split up into "words" REMOVING ALL whitespace. 'for' then puts each of those "words" into 'var', one at a time. 'for' should NOT be used for reading something that is line-based! See http://bash-hackers.org/wiki/doku.php?id=syntax:ccmd:classic_for greycat 1204047807 forget greycat 1204047900 learn The for command is for loops. for variable in WORDS # iterates over the list of WORDS (whitespace separated). for ((i=0; i<10; i++)) # is bash's C-like syntax. "help for" lhunath 1212132290 forget lhunath 1212132374 learn The statement ''for var in ...'' iterates over WORDS. Do NOT use it to iterate over anything e lhunath 1212132413 forget lhunath 1212132544 learn The statement ''for var in ..'' iterates over WORDS. Do NOT use it to iterate over output of an application that is not strictly words (like filenames!). for ((i=0; i < n; i++)) is the C-like syntax to iterate over a numeric range. lhunath 1227794124 forget lhunath 1227794491 learn The ''for var in ..'' statement iterates over arguments. for ((i=0; i < n; i++)) iterates over a numeric range. To iterate over filenames, use ''for file in [glob]''. Do *NOT* do ''for foo in `...`'': For will iterate over resulting WORDS, NOT the "filenames", or "lines" that the command outputs. lhunath 1227796351 forget lhunath 1227796419 learn The ''for var in ..'' statement iterates over arguments. for ((i=0; i < n; i++)) iterates over a numeric range. To iterate over filenames, use ''for file in [glob]''. Do *NOT* do ''for foo in `cat,ls,find,...`'': Here, for will iterate over resulting WORDS, NOT the "filenames", or "lines" that the command outputs. ormaaj 1445262105 forget ormaaj 1445262574 learn The ''for var in words'' (POSIX) compound command iterates over arguments. ''for ((i=0; i < n; i++))'' (bash/ksh93) iterates via a math expression. To iterate over filenames, use ''for file in [glob]''. Do *NOT* do ''for foo in `cat,ls,find,...`''! It won't do what you expect! http://wiki.bash-hackers.org/syntax/ccmd/classic_for http://wiki.bash-hackers.org/syntax/ccmd/c_for izabera 1454570145 forget izabera 1454570172 learn The ''for var in words'' (POSIX) compound command iterates over arguments. ''for ((i=0; i < n; i++))'' (bash/ksh93) iterates via a math expression. To iterate over filenames, use ''for file in [glob]''. Do *NOT* do ''for foo in `cat,ls,find,...`''! It won't do what you expect! http://wiki.bash-hackers.org/syntax/ccmd/classic_for http://wiki.bash-hackers.org/syntax/ccmd/c_for izabera 1454570338 forget izabera 1454570341 learn The ''for var in words'' (POSIX) compound command iterates over arguments. ''for ((i=0; i < n; i++))'' (bash/ksh93) iterates via a math expression. To iterate over filenames, use ''for file in [glob]''. Do *NOT* do ''for foo in `cat,ls,find,...`''! It won't do what you expect! http://wiki.bash-hackers.org/syntax/ccmd/classic_for