I have a program that requires arbitrary number of files. It works like
./code output.txt file1 file2 file3
And I have thousand of input files for it: file1, file2, ..., file1000.
However
I can split the input files in different sets. For example, combining 2 consequent input files:
./code output.txt file1 file2
./code output.txt file3 file4
...
(where output.txt is appending during each call of the code) Or, combining 3 consequent input files:
./code output.txt file1 file2 file3
./code output.txt file4 file5 file6
...
I found that xargs can be helpful for it:
ls file* | xargs -n3
The input is really splits into groups of three files.
But when I use xargs with more commands with 'I' option it passes to ./code just file1:
ls file* | xargs -n3 -I {} sh -c './code output.txt {}; command2; command3'
Could you please point out what am I doing wrong?
lsin a pipe. Noteecho file*(or betterprint) would do the same. It is notlsthat does the expansion.