I have a little problem: I have around two hundred files that must be treated individually (like "command file1", "command file2").
Of course, the program that must treat them doesn't accept wildcards. Is there any simple way of doing a "ls file*" and then redirecting its output line by line to the command I must run. Something that would look like this (in an imagined, C-like language):
filelist= ls; // suppossing that the outpout is an array of strings.
The xargs command is used to do that in bash programing. It takes the output of one command and pipes it to a new command one at a time. Check out this link for a nice practical discussion:
Absolutely not! The xargs command takes multiple "words" from standard input and gives them all as arguments so a single command; example:
find . -name *.java | xargs tar -cf backup.tar
What you need is a loop. Assuming you may have spaces in some filenames (in which case cutting into shell words doesn't work), you'd have to run something like this:
ls -1 | while read filename; do command "$filename"; done
Thanks a lot! Merci beaucoup!
De rien :) You're welcome!
I hope somebody can help me,I am in a trouble with this program.
I tried to do loop-in-loop,but it didn't work:( and I don't know how can I do it.I have read documentation about it but I couldn't find solution for my problem.
We try to cut a part from a picture,and the first loop worked,but if we have more pictures and want to do the same with the others how can I do it?
how can I make variable the img?
Thanks for any help in advance!
echo setting up variables
rm temp.* temp2.* temp3.* temp4*
proc2d $filenm.hed temp.hed first=0 last=0
while [ $rot -lt 360 ]; do
echo this will produce the circle - the hard way
proc2d temp.hed temp0.hed trans=0,$y1
proc2d temp0.hed temp2.hed trans=0,$y2
rm temp.* temp0.*
proc2d temp2.hed temp.hed rot=$rot
proc2d temp.hed temp3.hed
rm temp.* temp2.*
if [ $y1 -gt 0 ]; then y1=y1-1
if [ $y1 -eq 0 ]; then break
xargs can be told to work one file at a time like this:
|All times are GMT -5. The time now is 11:03 AM.|