This provides a way to sort output based on the length of the line, so that shorter lines appear before longer lines. It's an addon to the sort that I've wanted for years, sometimes it's very useful. Taken from my http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html Show Sample Output
Extracts ip addressess from file using sed. Uses a tag(ip) to grep the IP lines after extracting. Must be a way to just output regex matched on sed. Show Sample Output
The above output is for a custom compiled version of Vim on Arch Linux. Just a quick shell one liner, and presents a list of all the enabled and disabled (those prefixed with a '-') features. Show Sample Output
Create commands to download all of your Picasaweb albums Install Googlecl (http://code.google.com/p/googlecl/) and authenticate first. Show Sample Output
This uses some tricks I found while reading the bash man page to enumerate and display all the current environment variables, including those not listed by the 'env' command which according to the bash docs are more for internal use by BASH. The main trick is the way bash will list all environment variable names when performing expansion on ${!A*}. Then the eval builtin makes it work in a loop.
I created a function for this and use it instead of env. (by aliasing env).
This is the function that given any parameters lists the variables that start with it. So 'aae B' would list all env variables starting wit B. And 'aae {A..Z} {a..z}' would list all variables starting with any letter of the alphabet. And 'aae TERM' would list all variables starting with TERM.
aae(){ local __a __i __z;for __a in "$@";do __z=\${!${__a}*};for __i in `eval echo "${__z}"`;do echo -e "$__i: ${!__i}";done;done; }
And my printenv replacement is:
alias env='aae {A..Z} {a..z} "_"|sort|cat -v 2>&1 | sed "s/\\^\\[/\\\\033/g"'
From: http://www.askapache.com/linux-unix/bash_profile-functions-advanced-shell.html
Show Sample Output
change the nfl in the url to mlb or nba to get those score/times as well Show Sample Output
First set the variable $hexchars:
hexchars="0123456789ABCDEF"
Change the number in the first for loop if you need less then 1200 mac addresses
Show Sample Output
Used this command recently to remove the trailing ?> from all the files in a php project, which has having some unnecessary whitespace issues. Obviously, change *.php to whatever you'd like.
This is just a slight alternative that wraps all of #7917 in a function that can be executed Show Sample Output
Shows the IO of the raid sync
(1) required: python-googl ( install by: pip install python-googl ) (2) get from google API console https://code.google.com/apis/console/ Show Sample Output
Optionally, pipe the output into http://sed.sourceforge.net/grabbag/scripts/html2iso.sed Or: wget -qO - http://www.asciiartfarts.com/random.cgi | sed -n '//,//p' | sed -n '/ Show Sample Output
The original command is great, but I often want to prepend to every line. Show Sample Output
This modifies the output of ls so that the file size has commas every three digits. It makes room for the commas by destructively eating any characters to the left of the size, which is probably okay since that's just the "group". Note that I did not write this, I merely cleaned it up and shortened it with extended regular expressions. The original shell script, entitled "sl", came with this description: : ' : For tired eyes (sigh), do an ls -lF plus whatever other flags you give : but expand the file size with commas every 3 digits. Really helps me : distinguish megabytes from hundreds of kbytes... : : Corey Satten, corey@cac.washington.edu, 11/8/89 : ' Of course, some may suggest that fancy new "human friendly" options, like "ls -Shrl", have made Corey's script obsolete. They are probably right. Yet, at times, still I find it handy. The new-fangled "human-readable" numbers can be annoying when I have to glance at the letter at the end to figure out what order of magnitude is even being talked about. (There's a big difference between 386M and 386P!). But with this nifty script, the number itself acts like a histogram, a quick visual indicator of "bigness" for tired eyes. :-) Show Sample Output
Thanks to knoppix5 for the idea :-)
Print selected lines from a file or the output of a command.
Usage:
every NTH MAX [FILE]
Print every NTH line (from the first MAX lines) of FILE.
If FILE is omitted, stdin is used.
The command simply passes the input to a sed script:
sed -n -e "${2}q" -e "0~${1}p" ${3:-/dev/stdin}
print no output
sed -n
quit after this many lines (controlled by the second parameter)
-e "${2}q"
print every NTH line (controlled by the first parameter)
-e "0~${1}p"
take input from $3 (if it exists) otherwise use /dev/stdin
{3:-/dev/stdin}
Show Sample Output
Replace all instances of "A" with "B" in file "source" saved as file "destination". !! IF A/B is multi-byte, then separate bytes with spaces like so: "s/20\ 0A/00/g". Show Sample Output
Print a git log (in reverse order) giving a reference relative to HEAD.
HEAD (the current revision) can also be referred to as HEAD~0
The previous revision is HEAD~1 then HEAD~2 etc.
.
Add line numbers to the git output, starting at zero:
... | nl -v0 | ...
.
Insert the string 'HEAD~' before the number using sed:
... | sed 's/^ \+/&HEAD~/'
.
Thanks to bartonski for the idea :-)
Show Sample Output
Use -i to edit file directly: sed -i 's|\\|\/|g' file Show Sample Output
Extracts only file number 12 from file. It's meant for text files. Replace 12 with the number you want. First line starts at 1 not 0. We use q on next line so doesn't process any line more.
populate the auth.hosts file with a list of IP addresses that are authorized to be in use and when you run this command it will return the addresses that are pingable and not in the authorized list. Can be combined with the "Command line Twitter" command to tweet unauthorized access. 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: