Linux Tutorial Series

Linux Tutorial Series – 73 – The xargs command

Here is the video version, if you prefer it:

Let’s talk about the xargs command. The xargs command is used to accept input from the standard input and then converting it into an argument list for a specified command. (Shotts, 2019)⁠

Let’s look at an example:

mislav@mislavovo-racunalo:~/Linux_folder$ find /home -name 'ab*' -print | grep Linux_folder | xargs ls -l

-rw-r--r-- 1 mislav mislav 12 Feb 5 22:48 /home/mislav/Linux_folder/ab2.txt

-rw-r--r-- 1 mislav mislav 63 Jan 13 05:17 /home/mislav/Linux_folder/aba.txt

-rw-r--r-- 1 mislav mislav 0 Jan 11 23:00 /home/mislav/Linux_folder/aba.txt~

-rw-r--r-- 1 mislav mislav 12 Jan 13 05:17 /home/mislav/Linux_folder/ab.txt

-rw-r--r-- 1 mislav mislav 0 Jan 11 23:00 /home/mislav/Linux_folder/ab.txt~

Here I use find and grep to find files starting with ab in my Linux_folder. Then I use xargs to use those results and pass it to ls -l so that I get the long listing of each of the resulting files.

I have almost never had the need to use xargs. I only used it once or twice as a part of the “use Google to find a solution to your problem”. In that way, it is immensely useful to know what xargs does.

Hope you learned something useful!


Shotts, W. (2019). The Linux Command Line, Fifth Internet Edition. Retrieved from Pages 252-253