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.
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:
You can simply run "largest", and list the top 10 files/directories in ./, or you can pass two parameters, the first being the directory, the 2nd being the limit of files to display.
Best off putting this in your bashrc or bash_profile file
Runs the identify command (from ImageMagick) on each jpg file in the current directory and returns image details according to the format parameter. The example here returns:
Filename FileSize Compression Width Height
More information about the available format options can be found here: http://www.imagemagick.org/script/escape.php
I usually redirect the output to a text file using "> listofdetails.txt" at the end. Spreadsheet magic can then be applied.
for file in `ls -t \`find . -name "*.zip" -type f\``; do
found=`unzip -c "$file" | grep --color=always "PATTERN"`;
if [[ $found ]]; then echo -e "${file}\n${found}\n"; fi
done
'newfile' will have content of 'file' minus first 55 lines
to delete first line only do:
tail +2 file > newfile
Implementation of `rename` for systems on which I don't have access to it.
touch -t 201208211200 first ; touch -t 201208220100 last ;
creates 2 files: first & last, with timestamps that the find command should look between:
201208211200 = 2012-08-21 12:00
201208220100 = 2012-08-22 01:00
then we run find command with "-newer" switch, that finds by comparing timestamp against a reference file:
find /path/to/files/ -newer first ! -newer last
meaning: find any files in /path/to/files that are newer than file "first" and not newer than file "last"
pipe the output of this find command through xargs to a move command:
| xargs -ifile mv -fv file /path/to/destination/
and finally, remove the reference files we created for this operation:
rm first; rm last;
Allows to change 'shell' compatible files execution bit even if their name is not *.sh
All files in the directory will be renamed replacing every space in the filename by "_" (underline) and converting upper case characters to lower case characters.
e.g. Foo Bar.txt --> foo_bar.txt
This command find which of your zip (or jar) files (when you have lots of them) contains a file you're searching for. It's useful when you have a lot of zip (or jar) files and need to know in which of them the file is archived.
It's most common with .jar files when you have to know which of the .jar files contains the java class you need.
To find in jar files, you must change "zip" to "jar" in the "find" command. The [internal file name] must be changed to the file name you're searching that is archived into one of the zip/jar files.
Before run this command you must step into the directory that contains the zip or jar files.
Helps to fix permissions when a user clobbers them in their home directory or elsewhere. Does not rely on file extension, but uses the `file` command for context.
Uses the command ts in order to add a timestamp on each line. This command is provided in the moreutils package on Debian, and you may need libtime-duration-perl to be able to format the date.
When working with jailed environments you need to copy all the shared libraries to your jail environment. This is done by running ldd on a binary which needs to run inside the jail. This command will use the output from ldd to automatically copy the shared libraries to a folder of your choice.