0

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/
  • 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
1

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

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

4

This should work for you:

xargs -a "$filename" -n 1 command
1

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
  • 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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