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:
Runs a diff on two files ignore comments and blank lines (diff -I=RE does not work as expected). Adapted from a post found on stackexchange.
Execute a process or list of commands in the given interval and output the difference in output.
Get the list of changed files between revision 43 and HEAD revision: svn diff . -r43:HEAD --summarize
Strip extra 8 characters from every line: cut -c9-99999
Copy the listed files to home/me/destination: cpio -pvdmu ~/destination
Make a plain copy (-p), list files being copied (-v), create needed directories (-d), preserve modification time (-m), overwrite unconditionally (-u)
Good for when your working on building a clean source install for RPM packaging or what have you. After testing, run this command to compare the original extracted source to your working source directory and it will remove the differences that are created when running './configure' and 'make'.
The command will make it easy to determine free IP ranges in a crowded sub-net.
I've been using colordiff for years. wdiff is the new fav, except its colors. Word delimited diffs are more interleaved, easing the chore of associating big blocks of changes.
this alternative shows the differences as they occur so that they are made plain
I use this a lot to sync changes between folders that don't share a SVN or GIT repository. If you want to preview the command before executing, just leave out the last part ("| sh")
The normal output of 'diff' is a wonderful thing. But just sometimes, you want something that is a little more... well... readable.
This is that command.
-d - (optional) find the minimal set of changes
-b - (optional) ignore changes in the amount of whitespace
-B - (optional) ignore changes that just insert or delete blank lines
-y - this is where the magic happens! Use the side-by-side output format.
-w $COLUMNS - more magic! Instead of using 80 columns, use the current width of the terminal.
It grabs the PID's top resource users with $(ps -eo pid,pmem,pcpu| sort -k 3 -r|grep -v PID|head -10)
The sort -k is sorting by the third field which would be CPU. Change this to 2 and it will sort accordingly.
The rest of the command is just using diff to display the output of 2 commands side-by-side (-y flag) I chose some good ones for ps.
pidstat comes with the sysstat package(sar, mpstat, iostat, pidstat) so if you don't have it, you should.
I might should take off the timestamp... :|
Output of this command is the difference of recursive file lists in two directories (very quick!).
To view differences in content of files too, use the command submitted by mariusbutuc (very slow!):
diff -rq path_to_dir1 path_to_dir2
You can compare directories on two different remote hosts as well:
diff -y <(ssh user1@host1 find /boot|sort) <(ssh user2@host2 find /boot|sort)
To avoid password-prompt on remote host just generate the rsa key locally and copy it to remote host:
ssh-keygen -t rsa
then
ssh you@server1 "mkdir .ssh"
then
scp .ssh/id_rsa.pub you@server1:; .ssh/authorized_keys2
I've been looking for this for a long time. Does anybody know how to do this in dash (POSIX shell)?
An alternative version might be:
exiftool img_1.jpg | diff - <(exiftool img_2.jpg)
If you have ever edited a locally checked out version of a file to tweak it for testing purposes, and came back to it over a weekend, you might have forgotten what you exactly changed. This command helps you see the differences between the the checked in SVN version, and the one you tweaked.