
Terminal - Commands using xargs - 646 results
function skreemplay() { lynx -dump "http://skreemr.com/results.jsp?q=$*" | grep mp3$ | sed 's/^.* //' | xargs mplayer }
This is sample output - yours may be different.
This use the Screemr search engine to play mp3 songs
ls -RAx | grep "svn:$" | sed -e "s/svn:/svn/" | xargs rm -fr
This is sample output - yours may be different.
du -x --max-depth=1 | sort -n | awk '{ print $2 }' | xargs du -hx --max-depth=0
This is sample output - yours may be different.
# du -x --max-depth=1 /var | sort -n | awk '{ print $2 }' | xargs du -hx --max-depth=0
0 /var/lock
128K /var/run
4.0K /var/crash
4.0K /var/games
4.0K /var/local
4.0K /var/opt
4.0K /var/tmp
8.0K /var/mail
692K /var/spool
7.2M /var/backups
13M /var/log
97M /var/www
236M /var/lib
539M /var/cache
891M /var
Provides numerically sorted human readable du output. I so wish there was just a du flag for this.
ls . | xargs file | grep text | sed "s/\(.*\):.*/\1/" | xargs gedit
This is sample output - yours may be different.
newest () { find ${1:-\.} -type f |xargs ls -lrt ; }
This is sample output - yours may be different.
find . -type f |xargs -I% sed -i '/group name/s/>/ deleteMissing="true">/' %
This is sample output - yours may be different.
Changed out the for loop for an xargs. It's a tad shorter, and a tad cleaner.
find . -type f -size +1100000k |xargs -I% du -sh %
This is sample output - yours may be different.
1.1G ./Downloads/huge_avi.avi
1.2G ./Downloads/another_huge_avi.avi
simple find -> xargs sort of thing that I get a lot of use out of. Helps find huge files and gives an example of how to use xargs to deal with them. Tested on OSX snow leopard (10.6). Enjoy.
ipcs -a | grep 0x | awk '{printf( "-Q %s ", $1 )}' | xargs ipcrm
This is sample output - yours may be different.
find -type d -name ".svn" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".svn" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
This is sample output - yours may be different.
[...]
f2e6bb247f110dcab63b4d38ff7b2dee ./themes/darkblue_orange/img/b_relations.png
f2e6bb247f110dcab63b4d38ff7b2dee ./themes/original/img/b_relations.png
f5309bd2a2fc5e512a0cc38ac6f10c09 ./themes/darkblue_orange/img/b_deltbl.png
f5309bd2a2fc5e512a0cc38ac6f10c09 ./themes/original/img/b_deltbl.png
f60bfbb7ce218a55650c1abbbbee06ae ./themes/darkblue_orange/img/s_lang.png
f60bfbb7ce218a55650c1abbbbee06ae ./themes/original/img/s_lang.png
f63a5ad833147eeb94adb4496ddbec41 ./themes/darkblue_orange/img/s_theme.png
f63a5ad833147eeb94adb4496ddbec41 ./themes/original/img/s_theme.png
f6ae61146ce3de8fa11b9e84e086bd04 ./themes/darkblue_orange/img/bd_drop.png
f6ae61146ce3de8fa11b9e84e086bd04 ./themes/original/img/bd_drop.png
f95d66c11bfed9198d13a278269c32b2 ./themes/darkblue_orange/img/s_loggoff.png
f95d66c11bfed9198d13a278269c32b2 ./themes/original/img/s_loggoff.png
[...]
Improvement of the command "Find Duplicate Files (based on size first, then MD5 hash)" when searching for duplicate files in a directory containing a subversion working copy. This way the (multiple dupicates) in the meta-information directories are ignored.
Can easily be adopted for other VCS as well. For CVS i.e. change ".svn" into ".csv":
find -type d -name ".csv" -prune -o -not -empty -type f -printf "%s\n" | sort -rn | uniq -d | xargs -I{} -n1 find -type d -name ".csv" -prune -o -type f -size {}c -print0 | xargs -0 md5sum | sort | uniq -w32 --all-repeated=separate
echo $(( $( cat count.txt | tr "\n" "+" | xargs -I{} echo {} 0 ) ))
This is sample output - yours may be different.
if you, like me, do not have the numsum, this way can do the same.
find filepath -type f -iname "*.html" -o -iname "*.htm" -o -iname "*.php" | xargs grep "Exception\|LGPL\|CODE1"
This is sample output - yours may be different.
This is sample output - yours may be different.
ls -Q *
"new file" "new file (another copy)" "new file (copy)"
ls -Q * | xargs -p rm
rm new file new file (another copy) new file (copy) ?...y
ls -Q will show the filenames in quotes. xargs -p rm will print all the filenames piped from ls -Q and ask for confirmation before deleting the files.
without the -Q switch, if we have spaces in names, then the files won't be deleted.
find directory/ |xargs grep -i "phrase"
This is sample output - yours may be different.
Recursive grep through directory for file.
ls /usr/bin | xargs whatis | grep -v nothing | less
This is sample output - yours may be different.
no loop, only one call of grep, scrollable ("less is more", more or less...)
find . -maxdepth 1 -type f| xargs sha1sum | sed 's/^\(\w*\)\s*\(.*\)/\2 \1/' | while read LINE; do mv $LINE; done
This is sample output - yours may be different.
dpkg -l | grep ^rc | awk '{print $2}' | sudo xargs dpkg -P
This is sample output - yours may be different.
echo $VARIABLE | xargs -d'\40' -n 6 echo
This is sample output - yours may be different.
Print out the contents of $VARIABLE, six words per line, ignoring any single or double quotes in the text. Useful when $VARIABLE contains a sentence that changes periodically, and may or may not contain quoted text.
find . -name "*.php" | xargs grep -il searchphrase
This is sample output - yours may be different.
This command will find all files recursively containing the phrase entered, represented here by "searchphrase". This particular command searches in all php files, but you could change that to just be html files or just log files etc.
exipick -zi | xargs exim -Mrm
This is sample output - yours may be different.
find /lib/modules/`uname -r`/ -type f -iname '*.o' -or -iname '*.ko' |grep -i -o '[a-z0-9]*[-|_]*[0-9a-z]*\.ko$' |xargs -I {} echo '# {}' >>/etc/modules.autoload.d/kernel-2.6
This is sample output - yours may be different.
# /etc/modules.autoload.d/kernel-2.6: kernel modules to load when system boots.
#
# Note that this file is for 2.6 kernels.
#
# Add the names of modules that you'd like to load when the system
# starts into this file, one per line. Comments begin with # and
# are ignored. Read man modules.autoload for additional details.
# For example:
# aic7xxx
# mixer-oss.ko
# pcm-oss.ko
# seq-device.ko
# seq-oss.ko
# snd-seq.ko
Whenever you compile a new kernel, there are always new modules. The best way to make sure you have the correct modules loaded when you boot is to add all your modules in the modules.autoload file (they will be commented) and uncomment all those modules you need.
Also a good way to keep track of the available modules in your system.
For other distros you may have to change the name of the file to /etc/modprobe.conf
grep -e `date +%Y-%m-%d` /var/log/dpkg.log | awk '/install / {print $4}' | uniq | xargs apt-get -y remove
This is sample output - yours may be different.
Adapted using your usefull comments !
ifconfig -l | xargs -n1 ipconfig getifaddr 2> /dev/null
This is sample output - yours may be different.
find dir -size -1024k -type f | xargs -d $'\n' -n1 ls -l | cut -d ' ' -f 5 | sed -e '2,$s/$/+/' -e '$ap' | dc
This is sample output - yours may be different.
The command gives size of all files smaller than 1024k, this information, together with disk usage, can help determin file system parameter (e.g. block size) or storage device (e.g. SSD v.s. HDD).
Note if you use awk instead of "cut| dc", you easily breach maximum allowed number of records in awk.
find . -name '*png' -printf '%h\0' | xargs -0 ls -l --hide=*.png | grep -ZB1 ' 0$'
This is sample output - yours may be different.
This is sample output - yours may be different.