bash - Unix sh Script confusion -



bash - Unix sh Script confusion -

i have script 1 of professors college gave modify cannot seem figure out does. can help me understand bit better?

for grep $i; done

from can gather greps value of variable i, file or directory. not familiar how command comes play. appreciate tips offer.

look isn't command, it's first parameter grep. search word look in file named $i. (grep not search folders unless pass in -r in grep -r $i.)

the confusing bit for i comes in words specified, for in 1 2 three run commands between do , done 3 times: 1 time variable i = "one", 1 time i = "two", , 1 time i = "three". however, bash manual explains if in isn't specified:

if ‘in words’ not present, command executes commands 1 time each positional parameter set, if ‘in "$@"’ had been specified [...].

so, in short, if script in file named foo.sh, calling foo.sh file1 file2 word look in files "file1" , "file2".

bash unix

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -