Yi Wang
Yi Wang

Reputation: 1

how to take standard input as the value of a command's option?

For example I want to take the content of file named "comment" to be the value of setattr's -v option, something like

cat comment | setfattr -n user.comment -v -  filewanttotaged

but this does not work, neither do

cat comment | xargs setfattr -n user.comment -v - filewantedtotaged

For the latter case, the content is treated as file arugment for setfattr, instead of value of option -v

So how to do this job? Thank you very much!

Upvotes: 0

Views: 193

Answers (1)

Chris Maes
Chris Maes

Reputation: 37782

you can use xargs, but make sure its arguments are not at the end, but after your "-v" option:

cat comment | xargs -i setfattr -n user.comment -v {} filewantedtotaged

Upvotes: 2

Related Questions