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:
calculate how many different lines between two files
outputs a history of logins on the server (top 10, when piped to 'head'); optional flags: '-a' put the hostname at the end of the line (good for long hostnames), '-i' post the IP instead of the hostname, '-F' put the full login and logout times, rather than short times.
Throttle download speed
aria2c --max-download-limit=100K file.metalink
Throttle upload speed
aria2c --max-upload-limit=100K file.torrent
Axel
--max-speed=x, -s x
You can specify a speed (bytes per second) here and Axel will
try to keep the average speed around this speed. Useful if you
don?t want the program to suck up all of your bandwidth.
This line unbuffers the interactive output of rsync's --progress flag
creating a new line for every update.
This output can now be used within a script to make actions (or possibly piped into a GUI generator for a progress bar)
Sometime you need to monitor file or direcory change in dimension or other attributes. This command output file (called myfile in the example) attributes in the top of the screen, updating each 1 second.
You should change update time, command ( e.g., ls -all ) or target ( myfile, mydir, etc...).
Creates a PDF from multiple images. One page per image.
If you want a specific arbitrary order you can use {1,3,5,10,12}
* you may use jpg, tif etc
** if you do use jpg images you might want to add "-compress Zip" as suggested below to prevent from having the images from being re-compressed.
Usefull if you only want to see the package names, or if you want to use them in a script.
vim can open ssh/sftp and ftp connections for file editing using 'netrw'. If no path or file is provided vim opens the directory as a filelist.
See: :help netrw.
zsh globbing and glob qualifier:
'**/*' = recursive
om = ouput by modification (last access)
[1,20] = twenty files.
The '-t' switch is provided to ls so that the files are ordered with the most recent at the top. For a more 'find' like output the following can be used.
print -rl **/*(om[1,20])
example of the use of zsh glob qualifiers:
"@" = the symlink qualifier
"[1]" = first element
:t = remove leading path components, leaving the tail
perfect on a crashed system where you can't use commands like last. for investigation purposes wtmp file can be copied over to a different server and read with utmpdump
A method for aquiring the ip address using zsh. If you prefer the use of iproute2 (which, frankly, you should) then the following should provide the same (ip outputs CIDR addresses):
print ${$(ip -o -4 a s eth0)[4]}
we could also pass a qualifier to take only the IP and not the (CIDR) mask
print ${$(ip -o -4 a s eth0)[4]:h}
or, similarly, for the MAC address:
print ${$(ip l l eth0)[15]}
zsh:
"**/*" = recursive
"(.Lm+100)" "." = files, "L" = filesize glob qualifier, "m" = mb, "+100" = 100
I use these command to validate twitter accounts, we can use a "for a in $(cat list.txt)" to validate a complete list of twitter accounts.
example of zsh globbing and glob qualifiers:
"**/*" recursive
(.m0) '.' = regular file, 'm0' = modified zero days (so, today).
Finds files modified today since 00:00, removes ugly dotslash characters in front of every filename, and sorts them.
*EDITED* with the advices coming from flatcap (thanks!)
from http://git-scm.com/book/en/Git-Tools-Stashing
Useful for when stash cannot be applied to current branch