shell script - process directory
I'm trying to write a script that will search a directory and do something with all of the files in the directory. Here is what i have so far.
for show in /mydirectory do echo $show #it will do more, just when i can get it to work. done when i run the script it shows /mydirectory instead of showing all of the files. Probably an easy fix, i'm not a programmer (not yet) |
Quote:
Code:
for show in /mydir/* |
Try this tutorial out. It is a guide to writing bash scripts. Try this tutorial for learning the whole lot. And also of course the tldp.org Bash Guide for Beginners. Also use google a lot for searching... It is your best friend :)
Have fun learning |
'find' with the '-exec' option is your friend - you don't even have to take special care for spaces in file names :)
|
for file in `find . -type f -maxdepth 1 -print 2>/dev/null`
do echo $file done |
Quote:
Code:
find . -type f -maxdepth 1 -print #or ls |
Thanks for your help guys. I got it working.
|
ghostdog74: Yep, see the in-line comment in the OP
|
All times are GMT -5. The time now is 03:13 PM. |