KandZ – Tuts

We like to help…!

Linux CLI 36 🐧 xargs and touch commands

a - xargs command 

xargs reads reads from standard input and execute a command
you can use it to perform operations in multiple files or directories
echo "hello world" | xargs echo @ → reads the string and and add it to echo
ls -d */ | xargs ls -lh @ → reads all directories and list them with long and human readable format
xargs -a aaa.txt → like cat command displays the contents of a file
common commands: -L → limits the input lines per command
-P → runs multiple commands in parallel -I → replaces `@` with each input line as an argument instead of whitespace


b - touch command

touch is used to create new empty files
it is also used to update the timestamp of a file
It can do the above for one or multiple files
touch my.txt → creates an empty file
if the my.txt exists then it updates its timestamp
touch my1.txt my2.txt → creates empty files
touch myfile{1..5}.txt → creates 5 files using wildcards

Leave a Reply