Reputation: 833
Here is what I am trying to achieve. I want to run a sequence of commands on that file, so for example
ls * | xargs (cat - | calculateforfile)
I want to run (cat | calculateforthisfile)
on each of the file separately. So basically, how to group a list of commands as if it is one single function?
Upvotes: 1
Views: 94
Reputation: 2366
If you're looking for xargs
solution for this (for example find command)
find . -name "*.txt" | xargs -I % cat %
This will cat all the files found under current directory that end in .txt
The -I
option is the key there
Upvotes: 0
Reputation: 75558
No need to use xargs. Just use a loop. You also don't need to use cat
. Just redirect its input with the file.
for A in *; do
calculateforfile < "$A"
done
As a single line:
for A in *; do calculateforfile < "$A"; done
Upvotes: 1