Showing posts with label xargs. Show all posts
Showing posts with label xargs. Show all posts
Friday, March 21, 2008
Drag Windows From Anywhere
Here's a basic X windows tip. From any window manager, if you hold down the Alt key, you can drag a window from any position (the middle, the top, the bottom, etc...). This is handy when you don't want to move the mouse all the way up to the top toolbar to drag.
Thursday, March 13, 2008
Using xargs
I'm a big fan of the xargs command. It's widely used in shell scripts but not so much on the command line. It's a really handy command when you want to take an incoming argument and apply a command to it. Here's an example that would kill every process matching a given pattern of "firefox" (similar to killall).
ps aux | grep firefox | awk '{print $2}' | xargs kill -9
remove files matching *lock*:
ls *lock* | xargs rm
for more complex commands, you can set the incoming data to be stored in a token:
ls *lock* | xargs -I $ ls -l $
or
ls *lock | xargs -I {} ls -l {}
Obviously the possibilities go far beyond what's shown here. Play around with it.
ps aux | grep firefox | awk '{print $2}' | xargs kill -9
remove files matching *lock*:
ls *lock* | xargs rm
for more complex commands, you can set the incoming data to be stored in a token:
ls *lock* | xargs -I $ ls -l $
or
ls *lock | xargs -I {} ls -l {}
Obviously the possibilities go far beyond what's shown here. Play around with it.
Subscribe to:
Posts (Atom)