ksh's version of cd has an optional syntax where you can type "cd old new" and it will replace "old" with "new" in your current directory and take you there. This is very handy when you have a parallel directory structure, like source and object directories. As suggested, you can just type cd ${PWD/old/new} to get this in bash, but this function in your .bashrc will let you type the ksh cd syntax and avoid typing the special characters while preserving other cd functionality. Show Sample Output
The host command comes with the bind-utils package, which is has a better chance to be installed than resolveip from mysql. The last word of the query result is displayed, which is the last result host got. This works with CNAMEs. You get "3(NXDOMAIN)" in case of failure. Show Sample Output
the numbers in the ip address are represented in sed as \1\2\3\4. If I put \1\2\3$i, then I change the last number. So for example to change the second number I'll do \1$i\3\4. Regards, Kfir Show Sample Output
since we're repeating the command there after the semicolon, we only need one backtick Show Sample Output
Should run with sudo
Just to avoid link to itself
another one
Sometimes, it is annoying to find your files or directories missing. If you want to log all the rm commands you can put this in /etc/profile.
Another way to create temp files in your scripts, if tempfile fails, it will create a hidden local file in the current directory, don't forget to delete $FILE
Finds all tables that need optimising and loops through them, running optimise against them. This works server-wide, on all databases and tables.
If your contact information was entered when your user account was created (it gets added to /etc/passwd) then this gets that info and creates a QR code for you automatically
Cleaner, but probably less portable. Works with bash4 and should also work on bash3. IIRC, $(()) and (()) are bashisms, not POSIX. Show Sample Output
vim 7 required
Just an alternative. Here the output of the subshell statement is a complete script for dc so you can save it, manipulate it with some other tool or just debug it with less.
Lets say you have a file with the following layout: LINUX,DIR,FILE1,FILE2,FILE3 You want the file to look like this: LINUX,DIR,FILE1 LINUX,DIR,FILE2 LINUX,DIR,FILE3 This perl command does it for you. Show Sample Output
sudo /sbin/ifconfig | gotxt2imgmail you@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: