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/
Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
Mohammad AL-Rawabdeh
  • 1,612
  • 12
  • 33
  • 54

3 Answers3

4

This should work for you:

xargs -a "$filename" -n 1 command
Dennis Williamson
  • 62,149
  • 16
  • 116
  • 151
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
pjz
  • 10,595
  • 1
  • 32
  • 40
1

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

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

user9517
  • 115,471
  • 20
  • 215
  • 297