commandlinefu.com is the place to record those command-line gems that you return to again and again.
Delete that bloated snippets file you've been using and share your personal repository with the world. 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.
If you have a new feature suggestion or find a bug, please get in touch via http://commandlinefu.uservoice.com/
You can sign-in using OpenID credentials, or register a traditional username and password.
First-time OpenID users will be automatically assigned a username which can be changed after signing in.
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:
Prints a string indicating whether a command is an alias, keyword, function, builtin, or file. I have used this in my BASH scripts to allow an external parameter to define which function to run, and ensure that it is a valid function that can indeed be run.
Read all chapters up to 'Jumping', improve your effectiveness of wirking in terminal.
Most useful are the Moving and Searching commands
I find it useful when I want to add another crontab entry and I need to specify the appropriate PATH.
I give ''whichpath'' a list of programs that I use inside my script and it gives me the PATH I need to use for this script.
''whichpath'' uses associative array, therefore you should have Bash v4 in order to run it.
See sample output.
ulimit [-SHacdflmnpstuv [limit]]
Provides control over the resources available to the shell and to processes started by it, on systems that allow such control. The -H
and -S options specify that the hard or soft limit is set for the given resource. A hard limit cannot be increased once it is set; a
soft limit may be increased up to the value of the hard limit. If neither -H nor -S is specified, both the soft and hard limits are set.
# jumps straight to the definition of ulimit in the bash man page.
Usefull to detect if a commad that your script relies upon is properly installed in your box, you can use it as a function
function is_program_installed() {
type "$1" >/dev/null
}
Invoke it and check the execution code
is_program_installed "dialog"
if [ ! $? -eq 0 ]; then
echo "dialog is not installed"
exit 1
fi
The output will likely point to '/etc/alternatives/java'.
So find out where that points by issuing ls -l like this:
ls -l /etc/alternatives/java
The "type" builtin command is handy to find out what executable will be used if you issue a command. But on some distros, particularly when using /etc/alternatives, certain executables get buried under layers and layers of symbolic links and it becomes hard to find which one.
If you put the above command in your .bashrc, it adds a "-c" option to the type command that will weed through the symbolic links and prints the actual file that will be executed.
This command will format your alias or function to a single line, trimming duplicate white space and newlines and inserting delimiter semi-colons, so it continues to work on a single line.
Just after you type enter, you have 3 seconds to switch window, then "texthere" will be "typed" in the X11 application that has focus. Very useful to beat your score at games such as "How fast can you type A-Z".
get desired info from machine and pipe it txt file.