
Terminal - Commands using xargs - 522 results
lxc-ls | sort -u | xargs -i sudo lxc-info -n {}
This is sample output - yours may be different.
'lenny-pkg' is STOPPED
'lenny-www' is RUNNING
'squeeze-partial-pkg' is STOPPED
'squeeze-pkg' is RUNNING
This short snippet outputs the state of all containers available on your system. It is quite helpful to see which ones are running and which are stopped. Please notice that the "sort -u" is needed, otherwise running containers will be reported twice (see output of "lxc-ls" on its own for why)
function whichpkg() { readlink -f "$(which $1)" | xargs --no-run-if-empty dpkg -S; }
This is sample output - yours may be different.
$ function whichpkg(){ readlink -f "$(which $1)" | xargs --no-run-if-empty dpkg -S; }
$whichpkg rlogin
openssh-client: /usr/bin/ssh
This revision to my command (command #8851) was called for when it failed to find the parent
package of 'rlogin', which is really a deep symbolic link to /usr/bin/ssh.
This revision fixes this newfound issue, while ensuring fixes of other older issues work too.
find . -type f -print0 | xargs -0 rename 's/\ //g'
This is sample output - yours may be different.
delete file name space
the rename is rename perl version
unzip -l filename.zip |awk '{ if($4 != "Name" && $4 != "----") print $4}'|xargs -t rm -rf {}
This is sample output - yours may be different.
rm -rf {} OLE/ OLE/PPS/ OLE/PPS/File.php OLE/PPS/Root.php OLE/package.xml OLE/OLE.php OLE/PPS.php Spreadsheet/ Spreadsheet/Excel/ Spreadsheet/Excel/Writer.php Spreadsheet/Excel/package.xml Spreadsheet/Excel/Writer/ Spreadsheet/Excel/Writer/Parser.php Spreadsheet/Excel/Writer/Workbook.php Spreadsheet/Excel/Writer/Validator.php Spreadsheet/Excel/Writer/Format.php Spreadsheet/Excel/Writer/Worksheet.php Spreadsheet/Excel/Writer/BIFFwriter.php CSVtoXLS.php example.csv README.txt
Sometimes you unzip a file that has no root folder and it spews files all over the place. This will clean up all of those files by deleting them.
grep -rlZ oldstring . | xargs -0 sed -i -e 's/oldstring/newstring/'
This is sample output - yours may be different.
Using -Z with grep and -0 with xargs handles file names with spaces and special characters.
#!/bin/bash find | grep -P -v "(class)|(zip)|(png)|(gz)|(gif)|(jpeg)|(jpg)" | xargs -I @ grep -H $1 @
This is sample output - yours may be different.
./Main.java:// public static void main(String[] args) throws IOException
calls grep on all non-binary files returned by find on its current working directory
for each in /usr/bin/*; do echo $each | sed 's/\/usr\/bin\///' | xargs touch; done
This is sample output - yours may be different.
This will make a false directory with the same file names as whatever directory you choose. This is wise to use when testing scripts that alter contents, filenames, or move files. I wrote this after an OOPS I made when renaming a directory of JPGs, PNGs, PSDs that were mixed. I recommend this as I lost over 2000 vacation pictures and some graphics I designed for software and web sites. :(
NOTE: This only creates name copies, that data itself is not copied.
svn status|grep -iR '^!'|sed 's/!/ /g'|xargs -i svn rm '{}'
This is sample output - yours may be different.
Helps if you accidentally deleted files from an svn repo with plain rm and you would like to mark them for svn to delete too.
LC_ALL=C diff -q dir1 dir2 | grep differ | awk '{ print $2, $4 }' | xargs -n 2 gvim --nofork -d
This is sample output - yours may be different.
LC_ALL=C is here to always grep on "differ" whatever your language env.
xargs -n 2 to run gvim -d with 2 arguments
gvim --nofork to use only one instance of gvim
find . -type f | xargs grep -n "Old Text" | tee filesChanged.txt | sed 's/:.*$//' | xargs sed -i 's/Old Text/New Text/g
This is sample output - yours may be different.
find -iname \*.pdf -print0 | xargs -0 pdfgrep -i "my search text"
This is sample output - yours may be different.
svn st -q | cut -c 2- | tr -d ' ' | xargs tar -czvf ../backup.tgz
This is sample output - yours may be different.
This works more reliable for me ("cut -c 8-" had one more space, so it did not work)
find . -type f | xargs grep -l "string"
This is sample output - yours may be different.
Finds a string in files recursively below the current directory on systems without the "egrep" and its "-r" functionality.
grep -lr -e '<oldword>' * | xargs sed -i 's/<oldword>/<newword>/g'
This is sample output - yours may be different.
- grep for the word in a files, use recursion (to find files in sub directories), and list only file matches
-| xargs passes the results from the grep command to sed
-sed -i uses a regular expression (regex) to evaluate the change: s (search) / search word / target word / g (global replace)
find . -iname '*.conf' | xargs grep "searh string" -sl
This is sample output - yours may be different.
-sl : show just file names
allVideos() { find ./ -type f -print0 | xargs -0 file -iNf - | grep ": video/" | cut -d: -f1; }
This is sample output - yours may be different.
$ find ./ -type f -print0 | xargs -0 file -iNf - | grep ": video/" | cut -d: -f1
./.v.a-desk/atomic_city.wmv
./.mozilla/firefox/yhszbu0k.default/Cache/1/1A/9DD36d01
./.mozilla/firefox/yhszbu0k.default/Cache/7/A6/8BFE0d01
./.mozilla/firefox/yhszbu0k.default/Cache/6/63/FAE2Cd01
./.mozilla/firefox/yhszbu0k.default/Cache/9/D5/E16E0d01
$
Videos are found using their MIME type. Thus no need to for an extension for the video file.
This is a efficent version of "jnash" cmd (4086). Thanks for jnash. This cmd will only show video files while his cmd show files having "video" anywhere in path.
find . -name "directory_name" -type d -print0 | xargs -0 -i rm -rf {}
This is sample output - yours may be different.
sort -R /usr/share/dict/british | grep -v -m4 ^\{1,10\}$ | tr [:upper:] [:lower:] | tr "\n" " " | tr -d "'s" | xargs -0 echo
This is sample output - yours may be different.
trample tylenol parawing bycatch
Doesn't use shuf, its much faster with "shuf -n4" instead of sort -R
lsr() { find "${@:-.}" -print0 |sort -z |xargs -0 ls $LS_OPTIONS -dla; }
This is sample output - yours may be different.
=[9 h3xx@necronomicon ~ ]= $ lsr ~/.cron
drwx------ 10 h3xx users 304 Aug 13 01:45 /home/h3xx/.cron/
drwx------ 2 h3xx users 264 Aug 14 03:09 /home/h3xx/.cron/cron.01d/
-rwxr-xr-x 1 h3xx users 466 Jun 10 13:10 /home/h3xx/.cron/cron.01d/clean-chrome-tmp.sh*
-rwxr-xr-x 1 h3xx users 4973 Aug 13 22:59 /home/h3xx/.cron/cron.01d/clean-maildirs.sh*
-rwxr-xr-x 1 h3xx users 117 Aug 9 18:32 /home/h3xx/.cron/cron.01d/clean-thumbscache.sh*
-rwxr-xr-x 1 h3xx users 50 Aug 10 2010 /home/h3xx/.cron/cron.01d/linuxcounter.sh*
-rw-r--r-- 1 h3xx users 1264 Oct 12 2007 /home/h3xx/.cron/cron.01d/mkbackups.sh
-rw------- 1 h3xx users 375 Oct 7 2005 /home/h3xx/.cron/cron.01d/rcsync.sh
drwx------ 2 h3xx users 224 Aug 13 09:14 /home/h3xx/.cron/cron.01h/
-rw-r--r-- 1 h3xx users 937 Dec 31 2010 /home/h3xx/.cron/cron.01h/.bash-history.sh-notworking
-rwxr-xr-x 1 h3xx users 433 Aug 13 09:14 /home/h3xx/.cron/cron.01h/getmail-3.sh*
-rwxr-xr-x 1 h3xx users 4427 Jul 6 2010 /home/h3xx/.cron/cron.01h/randsig.pl*
-rw-r--r-- 1 h3xx users 1358 Aug 17 2010 /home/h3xx/.cron/cron.01h/stupid-curl
-rwxr-xr-x 1 h3xx users 172 Aug 13 00:09 /home/h3xx/.cron/cron.01h/waffles-log.sh*
drwxr-xr-x 2 h3xx users 80 Dec 31 2010 /home/h3xx/.cron/cron.01m/
-rw------- 1 h3xx users 218 Mar 27 2006 /home/h3xx/.cron/cron.01m/vidcap.sh
drwx--x--x 2 h3xx users 48 Mar 21 2008 /home/h3xx/.cron/cron.05m/
drwx------ 2 h3xx users 160 Aug 2 03:31 /home/h3xx/.cron/cron.07d/
-rwxr-xr-x 1 h3xx users 140 Apr 20 2009 /home/h3xx/.cron/cron.07d/clean-vim-views.sh*
-rwxr-xr-x 1 h3xx users 165 Apr 17 2008 /home/h3xx/.cron/cron.07d/insert_bash_history.sh*
-rwx--x--x 1 h3xx users 92 Sep 28 2010 /home/h3xx/.cron/cron.07d/logrotate.sh*
drwxr-xr-x 2 h3xx users 80 Aug 14 03:09 /home/h3xx/.cron/cron.15m/
-rwxr-xr-x 1 h3xx users 433 Aug 13 09:14 /home/h3xx/.cron/cron.15m/getmail-1.sh*
drwxr-xr-x 2 h3xx users 96 Aug 14 03:09 /home/h3xx/.cron/cron.30d/
-rwxr-xr-x 1 h3xx users 752 Aug 13 23:50 /home/h3xx/.cron/cron.30d/bogofilter-db-maintenance.sh*
drwx------ 2 h3xx users 144 Aug 13 09:14 /home/h3xx/.cron/cron.30m/
-rwxr-xr-x 1 h3xx users 367 Jan 23 2010 /home/h3xx/.cron/cron.30m/dyndns-update*
-rw-r--r-- 1 h3xx users 433 Aug 13 09:14 /home/h3xx/.cron/cron.30m/getmail-2.sh
lrwxrwxrwx 1 h3xx users 26 Aug 18 2008 /home/h3xx/.cron/cron.30m/process-spam.sh -> ../../libs/process-spam.sh
-rwx--x--x 1 h3xx users 4125 Aug 13 01:41 /home/h3xx/.cron/install-crontab*
-rwx--x--x 1 h3xx users 4122 Aug 13 01:34 /home/h3xx/.cron/install-crontab~*
=[9 h3xx@necronomicon ~ ]= $
Tells you everything you could ever want to know about all files and subdirectories. Great for package creators. Totally secure too.
On my Slackware box, this gets set upon login:
LS_OPTIONS='-F -b -T 0 --color=auto'
and
alias ls='/bin/ls $LS_OPTIONS'
which works great.
svn st | grep '^?' | sed -e 's/\?[[:space:]]*//' | tr '\n' '\0' | xargs -0 svn add
This is sample output - yours may be different.
find . -type d -name 'CVS' | xargs rm -r
This is sample output - yours may be different.
pgrep -u username php5-fcgi | xargs kill -9
This is sample output - yours may be different.
vim -p `grep -r PATTERN TARGET_DIR | cut -f1 -d: | sort | uniq | xargs echo -n`
This is sample output - yours may be different.
find . -type d|xargs tar rf ~/dirstructure.tar --no-recursion
This is sample output - yours may be different.
The original suggestion did not work for me, when operating on folders located on an external mount (ie other than the root device) in Ubuntu. A variation using xargs does the trick.
ipcs -ma | awk '/^m / { if ($9 == 0) { print $2 }}' | xargs -n 1 ipcrm -m
This is sample output - yours may be different.
It can work for message queue, semaphore set or shared memory just changing the parameter.