I want to pass all the files as a single argument on Linux but I am not able to do that.
This is working
ls | sort -n | xargs -i pdftk {} cat outpu
The most intuitive way I found was to:
Here is an example to rename extensions from ".txt" to ".txt.json":
find .|grep txt$|xargs -I{} echo "mv {} {}.json"|bash
Slightly advanced example to rename .txt to .json (removing .txt extension)
find $PWD|grep txt$|cut -d"." -f1|xargs -I{} echo "mv {}.txt {}.json"|bash
I once had a requirement to append the string "End of File" to all files.
find .|grep txt|xargs -I{} echo "echo End of File >> {}"|bash
If you do it right, xargs is the king of all commands!
Use -I
option:
echo prefix | xargs -I % echo % post
Output:
prefix post