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:
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
This saves Subversion's log output as XML and then runs an XQuery over it. This is standard XQuery 1.0 and should therefore also work with other XQuery processors. I have tested it with Zorba (http://www.zorba-xquery.com). XQilla (http://xqilla.sourceforge.net) also does it, but you'd have to save the query to a file and then execute "xqilla filename.xq".
The query first finds all distinct authors and then, for each author, sums up the number of paths they have changed in each commit. This accounts for commits of multiple changes at once.
The indenting space in all lines from the second one seems to be due to a bug in Zorba.
To replace foo by bar, but not execute, do ^foo^bar^:p
To replace all foo by bar, but not execute, do ^foo^bar^:&:p
This command line creates a new user with home directory, using the command "useradd". The command "mkpasswd" lets you encrypt the password e.g. with SHA-512 method. This line ensures that your password is written encrypted in /etc/shadow" so you can log in with the new user.
The Pomodoro Technique is a time management method developed by Francesco Cirillo in the late 1980s. The technique uses a timer to break down periods of work into 25-minute intervals called 'Pomodori' (from the Italian word for 'tomatoes') separated by short breaks.
You need to prepare a short .wav file (the "ring.wav" in the sample command line). This command will trigger aplay to play ring.wav 25 minutes from now on, which can be used as a poor man's pomodoro timer.
zsh: add leading zero ... altogether pointless, as there can only be a maximum of 10 'single digit' files, and so a maximum of 10 files the command can act on. Padding further zeros will produce '0010', '001' and so break sequance. The only proper method is to itterate the numbers like so:
i=1; for f (*) zmv $f '${(l:3::0:)$((++i))}'.txt
but this has the unfortunate side effect of incrementing the values by 1 ... which may not be desirable.