Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sh loop on files

Status
Not open for further replies.

simanek

Programmer
Jan 19, 2001
137
0
0
US
Hi all,

I'm pretty new to doing anything requiring more than one line at a command prompt and was wondering how I would execute a command on all files in a directory using a 'for' loop (or any type of loop, it doesn't matter). Thanks. Mike
~~~~
simanek@uiuc.edu
"It's a Swingline!"
~~~~
 
just keep typing.....;)
the shell will interpret and put you at a second level (PS2)

#>for i in /usr/bin /bin /tmp
#2> do
#2> ls -ald $i
#2> done

unix42
 
Hello mike,

Do the following

$ for file in `ls -1`
> do
> echo "file is [$file]"
> # do whatever you want to do here
> done

Mohan
 
Or better still, put the above commands in a script and have it available all the time! Cheers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top