'how can I use lines in a file as arg and append a prefix to each arg in bash?
I have a file like this:
arg1
arg2
arg3
...
argN
I knew I can use xargs for this cat input.txt | xargs <my command>. However, I would like to append a prefix to each args so the result should be <my command> prefix/arg1 prefix/arg2 ...
The -I cannot work because it implies -L 1 and -x.
Solution 1:[1]
You could use sed to change the lines before piping them into xargs
sed 's/^/prefix\//' input.txt | xargs <my command>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | pmf |
