Use shell expansion rather than ls for file in *. {jpg,bmp,tif} do imagejob "$file" "output/${file%. Output}" done also if you have bash 4.0+, you can use globstar shopt -s globstar shopt -s nullglob shopt -s nocaseglob for file in **/*.
{jpg,bmp,tif} do # do something with $file done.
1 You're missing a closing quote. – Dennis Williamson Feb 28 '11 at 5:35 @Dennis. Thks for noticing.
– kurumi Feb 28 '11 at 6:13 how do I specify the directory to run this script under? – ash Mar 1 '11 at 5:21 im getting an error cannot stat `*. {jpg,bmp,tif}': No such file or directory – ash Mar 2 '11 at 2:04 This solution doesn't work for directories containing a large number of files; it fails with the error "Argument list too long".
– sampablokuper Aug 18 '11 at 17:16.
For I in `ls $1/*. Jpg $1/*. Bmp $1/*.
Tif`; do imagejob "$i"; done This is assuming you're using a bashlike shell where $1 is the first argument given to it. You could also do: find "$1" -iname "*. Jpg" -or -iname "*.
Bmp" -or -iname "*. Tif" \ -exec imagejob \{\}.
1 using ls to list files with a for loop is bad practice – kurumi Feb 28 '11 at 4:29 The find solution is nice but will find names recursively. The shell globbing method might break with spaces in file names. – Noufal Ibrahim Feb 28 '11 at 4:45 The curly braces don't need to be escaped.
– Dennis Williamson Feb 28 '11 at 5:37.
You could use a construct with backticks and ls (or any other commando of course): for f in `ls *. Jpg *. Bmp *.
Tif`; do ...; done.
I know it's a problem with spaces, and very large dirs, but it seems sufficient for other cases. I think your solution is better in this case, but what if I want to use sorting options of ls/pipe its output through another command? – markijbema Feb 28 '11 at 4:42 1 it's to prevent future cases of whitespaces in file names.
(Also, its what people call, useless use of ls). Why wait for your code to break when you can prevent it in the first place. If you need to use other options coupled with ls, use a while read loop (or you can set IFS ) – kurumi Feb 28 '11 at 5:33.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.