xargs - execute command lines from standard input - Video Man Pages @DistroTube
xargs - execute command lines from standard input - Video Man Pages  @DistroTube
Uploaded February 2026 | Updated November 2026, 1 day ago
'xargs' takes the output of one command (or contents of a file), converts it into a list of arguments, and passes that list to another command to execute.

- Run a command using the input data as arguments:
command1 | xargs command2

- Count lines in multiple files:
ls *.txt | xargs wc -l

- Cat a file and use the input data as an argument:
cat file | xargs
NOTE If no xargs command is given, xargs uses 'echo' as the command.

- The same as above except it executes the command once per argument (-n 1):
cat file | xargs -n 1

- Create 10 sequential .txt files. The '-I {}' symbolizes all the input:
seq 10 | xargs -I {} touch {}.txt

- Delete files with '.log' extension found by 'find'. The -print0 in 'find' and -0 in 'xargs' use a null character as a delimiter, ensuring filenames with spaces or special characters are handled correctly.
find . -name "*.log" -print0 | xargs -0 rm -f

- Find and delete all backup files (.bak). The '-p' option is useful for destructive operations, as it displays the command to be executed and asks for user confirmation (y/n).
find . -type f -name "*.bak" | xargs -p rm

- The '-d' option sets the delimiter (spaces by default):
ls | xargs -n 1 (Files/directories with spaces are a problem.)
ls | xargs -n 1 -d \n (Uses new line as delimiter and problem solved!)

- xargs can print (-a) the contents of a file to stdout. We can use '-p' to prompt for 'y/n' before executing. We can use '-r' to only execute if stdin is not empty.
xargs -a 1.txt
xargs -p -a 1.txt
xargs -r -p -a 1.txt

REFERENCED:
β–Ί gitlab.com/dwt1/vidman

WANT TO SUPPORT THE CHANNEL?
πŸ’° Patreon: patreon.com/distrotube
πŸ’³ Paypal: paypal.com/donate/?hosted_button_id=MW3ZFGS8Q9JGW
πŸ›οΈ Amazon: amzn.to/2RotFFi
πŸ‘• Teespring: teespring.com/stores/distrotube

DT ON THE WEB:
πŸ•ΈοΈ Website: http://distro.tube
πŸ“ GitLab: gitlab.com/dwt1
πŸ—¨οΈ Mastodon: fosstodon.org/@distrotube
πŸ‘« Reddit: reddit.com/r/DistroTube
πŸ“½οΈ Odysee: odysee.com/@DistroTube:2

FREE AND OPEN SOURCE SOFTWARE THAT I LIKE:
🌐 Brave Browser - brave.com
πŸ“½οΈ Open Broadcaster Software: obsproject.com
🎬 Kdenlive: kdenlive.org
🎨 GIMP: gimp.org
πŸ’» VirtualBox: virtualbox.org
πŸ—’οΈ Doom Emacs: github.com/hlissner/doom-emacs

Your support is very much appreciated. Thanks, guys!
xargs - execute command lines from standard input - Video Man PagesIs Artix Linux Just A Protest Distro?A New Folder Just Appeared In Your Home DirectoryHey, DT! Youre Not Bald...But You Are Wide! (Plus Other Comments)Dunst Adds Desktop Notifications To Your Window ManagerA Quick First Look At The Niri Window Manager5 Open Source Apps Id Install Even On WindowsHey, DT! Its Nice To See You Screw Things Up...Fsearch Is An Amazing File Searcher For LinuxIs The Fish Shell Annoying Because Its Different? (No...Its AWESOME!)Never EVER Apologize For Something You Didnt Do!A PDF Viewer With Vim Like Bindings And Configuration
DistroTube |

'xargs' - execute command lines from standard input - Video Man Pages

SHARE TO X SHARE TO REDDIT SHARE TO FACEBOOK WALLPAPER