Reputation: 5174
I want to run the following command in linux, python3 pythonScript.py filename1 filename2 filename3 filename4 filenameN.....
If I wanted to run the filenames as a list I would do python3 pythonScript.py $(< filenamelist.txt)
where filename list.txt contains filename1 filename2 filename3 filename4 filenameN.... in each line.
Is there a way I can run this command without generating the list and just feed the directory of filenames directly into the command?
Upvotes: 0
Views: 157
Reputation: 6551
You can use xargs
:
find somefolder -maxdepth 1 -print0 |xargs -0 python3 pythonScript.py
Upvotes: 2
Reputation: 7781
Try brace expansion.
python3 pythonscript.y filename{1..10}
N
limit to a variable, then you need a loop, because brace expansion happens before variable does in bash.Upvotes: 1