Directly send the content of a url to standard out. This command is most convenient for sending the output of a download directly to another command. Show Sample Output
The shortest and most complete comment/blank line remover...
Any line where the first non-whitespace character is # (ie, indented # comments), and all null and blank lines are removed. Use the alias as a filter:
noc /etc/hosts
or
grep server /etc/hosts | noc
Change to nawk depending awk versions.
Show Sample Output
A quick alias I use right before logging into a server so that I have a log of the transactions as well as the ability to re-connect from another computer. Useful for when your boss says "what commands did you run again on that server?" and you had already closed the terminal ;) I wrapped it in a script now, with more features, but this is the heart of it. Never leave home without it.
On laptops featuring hybrid graphics and using the free X drivers, the DRI_PRIME variable indicates which GPU to run on. This alias allows to utilize the faster discrete GPU without installing proprietary drivers. Show Sample Output
Output the current time in Swatch “Internet Time”, aka .beats. There are 1000 .beats in a day, and @0 is at 00:00 Central European Standard Time. This was briefly a thing in the late 1990s. More details:
https://2020.swatch.com/en_ca/internet-time/
The alias is rather quote heavy to protect the subshell, so the bare command is:
echo '@'$(TZ=GMT-1 date +'(%-S + %-M * 60 + %-H * 3600) / 86.4'|bc)
Show Sample Output
Creates a command alias ('cr' in the above example) that searches the contents of files matching a set of file extensions (C & C++ source-code in the above example) recursively within the current directory. Search configured to be in colour, ignore-case, show line numbers and show 4 lines of context. Put in shell initialisation file of your choice. Trivially easy to use, e.g:
cr sha1_init
Show Sample Output
If you come from a DOS background and accidentally use DOS commands often, this and others like it can be helpful. Add to your .bash_profile, or wherever you keep such things.
similar to perl chop()
An easy way to create aliases for moving between many directories Show Sample Output
By 'pst' you can print out process tree with all details about all processes (including a command line, PID, and the current process you are running in). By 'pst username' you can get an information about processes belonging to the particular user 'username'. Show Sample Output
Just type 'opened' and get all files currently opened for edit.
parses the output of ifconfig to show only the configured ip address (in this case from interface eth0). the regexp is quick'n'dirty im sure it can be done in a better way. --> this alias does not show your "internet ip" when you're in a nat-environment Show Sample Output
Reads in the ~/.Xdefaults lexicographically sorted with, instead of replacing, the current contents of the specified properties.
This alias finds identical lines in a file (or pipe) and prints a sorted count of them (the name "sucs" descends from the first letters of the commands). The first example shows the number of logins of users; the one who logged in most often comes last. The second example extracts web client IP addresses from a log file, then pipes the result through the "sucs" alias to find out which clients are performing the most accesses. Or pipe the first column of ps(1) output through "sucs" to see how many processes your users are running. Show Sample Output
# newline to space; the whack before dollar-underbar is required
alias nl2space="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{ }, @F) , qq{\n};}' "
# newline to comma; the whack before dollar-underbar is required
alias nl2,="perl -ne 'push @F, \$_; END { chomp @F; print join(qq{,}, @F) , qq{\n};}' "
PROMPT> cat /tmp/foo
foo-001
foo-002
foo-003
foo-004
foo-005
foo-006
foo-007
foo-008
foo-009
foo-010
# 'tr' does not give a newline after it run. Makes a messy commandline.
PROMPT> cat /tmp/foo|tr "\n" ' '
foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010 $PROMPT> tr "\n" ' ' /tmp/foo
# 'tr' does not take arguements
PROMPT> tr "\n" ' ' /tmp/foo
tr: extra operand `/tmp/foo'
Try `tr --help' for more information.
# 'nl2space' is a filter and takes arguements, adds a newline after it runs.
PROMPT> cat /tmp/foo| nl2space
foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010
PROMPT> nl2space /tmp/foo
foo-001 foo-002 foo-003 foo-004 foo-005 foo-006 foo-007 foo-008 foo-009 foo-010
I rarely need this, but I have a hard time remembering the command when I need it. Admit it. This has happened to you. Yes this is bad, and you better clean up now. Borrowed from http://thoughtsbyclayg.blogspot.com/2008/02/how-to-delete-last-command-from-bash.html Show Sample Output
Define commands that you always invoke with an appended '&disown'. In the example:
gvim foo.txt
will open gvim dettached from the current terminal.
Often I need to diff two files and want the output side by side for ease of reading and I don't want to see common lines. With this alias I just: differ file1 file2
Normally the bash builtin command 'set' displays all vars and functions. This just shows the vars. Useful if you want to see different output then env or declare or export.
Alias 'sete' shows sets variables
alias sete='set|sed -n "/^`declare -F|sed -n "s/^declare -f \(.*\)/\1 ()/p;q"`/q;p"'
Alias setf shows the functions.
alias setf='set|sed -n "/^`declare -F|sed -n "s/^declare -f \(.*\)/\1 ()/p;q"`/,\$p"'
Also see: http://www.commandlinefu.com/commands/view/6899/print-all-environment-variables-including-hidden-ones
At the very least, some cool sed commands!
From my .bash_profile http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
Sets an alias to remote desktop to the specified console, along with options to ensure the RDP session takes up the whole screen, includes a home directory mapping, and clipboard mappings. Show Sample Output
This alias is quicker to type than 'sudo apt-get install', and it automatically says yes to the prompt that shows up sometimes.
This is for bash - make an alias - also a good blueprint for making aliases that take arguments to functions. If for Solaris use "-size +${1}000000c" to replace "-size +${1}M" Show Sample Output
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: