Pacific-Design.com

    
Home Index

1. Bash

2. xargs

Bash / xargs /

xargs - execute a command once per line of piped input.

#-- text.txt --#
one
two
three

#-- receiver.sh --#
#!/bin/bash
echo "Line="$1

# -- execute ---#
cat text.txt | xargs -n1 ./receiver.sh

#-- output --#
Line=one
Line=two
Line=three

Find and copy file into destination

$ grep -lir 'link' . | xargs cp -t /home/kevin/facebook-powereditor/link/
$ find . -type f -exec grep -q '^beginString' {} \; -exec cp -t /home/user/DestinationFolder {} +