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 delete empty directories and directories which only contain empty directories using zsh globbing syntax. ** is for recursive globbing. *(/^F) matches all entries that are directories which are not full.
If you only want to delete empty directories and not those directories which contained only empty directories and will be empty afterwards, just leave out the options to rmdir:
rmdir **/*(/^F)
recursively deletes all broken symlinks using zsh globbing syntax.
end_w_nl filename
will check if the last byte of filename is a unix newline character. tail -c1 yields the file's last byte and xxd converts it to hex format.
commandlinefu.com is the place to record those command-line gems that you return to again and again. 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.
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: