This is a simple example of a unix command, which recursively deletes backup files.
Many advanced text-editors (jEdit, emacs, vim) produce temporary backup copies of edited files.
They usually look Like "file~" (with tilde at the end). While it's not a bad idea to have backup files,
they are not needed if you want, for example, redistribute your source code.
We use find command to find all *~ files beginning from current directory. $ find ./ -name '*~' -print To include .*~ files (beginning with dot) we're adding -or clause to find. $ find ./ -name '*~' -print -or -name ".*~" -print Finally, we use -exec option of find to remove all found files.
$ find ./ -name '*~' -exec rm '{}' \; -print -or -name ".*~" -exec rm {} \; -print
So, this will remove every backup~ file beginning from current directory. source code: bash script
#!/bin/sh
echo "recursively removing backup files from"
pwd
find ./ -name '*~' -exec rm '{}' \; -print -or -name ".*~" -exec rm {} \; -print
You may save this script as /usr/bin/cbackup (or put in any other binary folder included in system's path) and use later to get 'clean' project source without typing lengthy commands.
|
|