Next time you are using your shell, try typing ctrl-x e (that is holding control key press x and then e). The shell will take what you've written on the command line thus far and paste it into the editor specified by $EDITOR. Then you can edit at leisure using all the powerful macros and commands of vi, emacs, nano, or whatever. Show Sample Output
List all process running a specfic port Show Sample Output
This assumes you have the 'rpm', 'rpm2cpio' and 'cpio' packages installed. This will extract the contents of the RPM package to your current directory. This is useful for working with the files that the package provides without installing the package on your system. Might be useful to create a temporary directory to hold the packages before running the extraction:
mkdir /tmp/new-package/; cd /tmp/new-package
A useful way to generate the MD5 hash for a string by command line Show Sample Output
Requieres unoconv (debian package)
After typing cd directory [enter] ls [enter] so many times, I figured I'd try to make it into a function. I was surprised how smoothly I was able to integrate it into my work on the command line. Just use cdls as you would cd. It will automatically list the directory contents after you cd into the directory. To make the command always available, add it to your .bashrc file. Not quite monumental, but still pretty convenient. Show Sample Output
Jan Nelson from Grockit came up with this for us when we needed to rename all of our fixtures.
Removes all unversioned files and folders from an svn repository. Also:
svn status --no-ignore | grep ^I | awk '{print $2}' | xargs rm -rf
will remove those files which svn status ignores. Handy to add to a script which is in your path so you can run it from any repository (a la 'svn_clean.sh').
What this does is, if I type ?ssh ? then hit the page-up key, it will complete the line to the last time in my history file that I typed ssh. Hitting page up again will go to the 2nd to last time I typed it. Incredibly handy if you ever type the same commands more than once.
credit goes to http://www.sharms.org/blog/2009/03/10/make-your-bash-shell-cool-again/
echo "\"\e[6~\": history-search-forward" >> ~/.inputrc
This will change all files ending in .JPG to .jpg and will work with any file extension
ssh -X example.org xeyes
The SSH server configuration requires:
X11Forwarding yes # this is default in Debian
And it's convenient too:
Compression delayed
Then, you can assign new accels to GTK menu actions pressing the keys while the option is active.
This was useful to generate random passwords to some webpage users, using the sample code, inside a bash script Show Sample Output
Sometimes you have a situation where you cannot properly see the ls output when you are using a terminal w/a dark background. Usually bash has ls aliased to use colors, and you can easily get ls to use the default foreground color via simply unaliasing the command.
works the same as R's t()
Use set +o noclobber and you will be able to replace files again Show Sample Output
This will get the job done in the most efficient way -
spawning only one `rm` process.
"On-the-fly" find data is displayed through `tee` and
you should have plenty of time to ctrl-c if needed before it's too late.
You may need to re-run this after major Software Updates.
To leave more languages in, add more ``-and \! -iname "lang*"'' statements:
sudo find / -iname "*.lproj" -and \! -iname "en*" -and \! -iname "spanish*" -print0 | tee /dev/stderr | sudo xargs -0 rm -rfv
**Edit: note the 2nd sudo near the end of the pipeline - this is necessary.
Add z to the flags to enable compression.
If the username includes an @ you can use this one: wget -r --user=username_here --password=pass_here ftp://ftp.example.com
commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.
Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.
» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10
Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):
Subscribe to the feed for: