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:
Only zsh supports it. This removes all the regular files in the current directory except for any .tex and .pdf files.
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'.
Uses zsh globbing syntax to safely remove all the files known to be generated by LaTeX, but only if there is actually a .tex source file with the same basename present. So we don't accidentally delete a .nav .log or .out file that has nothing to do with LaTeX, e/'[[ -f ${REPLY:r}.tex ]]'/ actually checks for the existance of a .tex file of the same name, beforehand.
A different way to do this, would be to glob all *.tex files and generate a globbing pattern from them:
TEXTEMPFILES=(*.tex(.N:s/%tex/'(log|toc|aux|nav|snm|out|tex.backup|bbl|blg|bib.backup|vrb|lof|lot|hd|idx)(.N)'/)) ;
rm -v ${~TEXTEMPFILES}
or, you could use purge() from grml-etc-core ( http://github.com/grml/grml-etc-core/blob/master/usr_share_grml/zsh/functions/purge )
recursively deletes all broken symlinks using zsh globbing syntax.
sed '$ d' foo.txt.tmp
...deletes last line from the file
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;
Code to delete file with gremlins/special characters/unicode in file name.
Use ls -i to find the INODE number corresponding to the file and then delete it using that find statement.
detailed here:
Like the above, but runs a single rm command
rm /SOME/PATH/*, when you hit "argument list too long".
This simple command removes all the .svn directories recursively. Useful when you want to get a clean code excluding .svn files.
Check what is getting delete through this command
" find . -name '.svn' -type d | xargs echo "
This command won't delete resource forks from an HFS file system, only from file systems that don't natively support resource forks.
Remove all zero size files from current directory. Its a not recursive option like:
find . -size 0c -exec rm {} \;
Remove all the hidden CVS merge helper files that I keep seeing in my IntellIj project
Here is the full function (got trunctated), which is much better and works for multiple queries.
function cmdfu () {
local t=~/cmdfu;
until [[ -z $1 ]]; do
echo -e "\n# $1 {{{1" >> $t;
curl -s "commandlinefu.com/commands/matching/$1/`echo -n $1|base64`/plaintext" | sed '1,2d;s/^#.*/& {{{2/g' | tee -a $t > $t.c;
sed -i "s/^# $1 {/# $1 - `grep -c '^#' $t.c` {/" $t;
shift;
done;
vim -u /dev/null -c "set ft=sh fdm=marker fdl=1 noswf" -M $t;
rm $t $t.c
}
Searches commandlinefu for single/multiple queries and displays syntax-highlighted, folded, and numbered results in vim.
similar to previous except this exports to a temporary file, opens that file with your default web browser, then deletes it.