I have a file contain list of path now I want to execute command on each line example :-

file name : rawabdeh .......
command : command

file contains:-

path/no/1/
path/no/2/
path/no/3/

I want to do the following :

command path/no/1/
command path/no/2/
command path/no/3/
link|improve this question

Does each line of your file contain multiple paths and do you want to run command on each of the multiple paths on every line ? – Iain Sep 21 '10 at 14:51
no no each line of file conten one path – Mohammad AL-Rawabdeh Sep 21 '10 at 15:05
feedback

3 Answers

up vote 1 down vote accepted

Replace input-file, command and output-file as you require

cat input-file | sed 's/^/command /' >output-file

link|improve this answer
feedback

This should work for you:

xargs -a "$filename" -n 1 command
link|improve this answer
feedback

I'm not sure I'm understanding your request completely, but if you have a list of paths in a file and want to execute the same command on each line in $filename, then you should do:

xargs -n 1 command < $filename
link|improve this answer
5  
xargs -n 1 command <$filename ;) – krissi Sep 21 '10 at 14:34
I'm not sure I'm understanding your request completely, but if you have a list of paths in a file and want to execute the same command on each LINE IN FILE – Mohammad AL-Rawabdeh Sep 21 '10 at 14:37
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.