Unix Tip: Avoiding the Oops

By  

-type d`
> do
> touch $dir/-i
> done

The only problems I can find with this little trick are 1) that your rm -rf commands will fall flat on their faces if you also have files named -a or -d (or any file names starting with a hyphen) because these file names will be interpreted as invalid options to the rm command, causing it to fail and 2) because the rm -rf command will ignore your -i file completely and remove your files without a second thought if you also have files beginning with some other oddball characters like $ (any characters that precede the hyphen in the ASCII character set and are allowable in file names) because files with names like $file will move your -i file further to the right in the resultant command, disrupting its interpretation as a command option.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

IT ManagementWhite Papers & Webcasts

Webcast On Demand

Transform Your IT Service Management

Sponsor: EasyVista

See more White Papers | Webcasts

Answers - Powered by ITworld

ITworld Answers helps you solve problems and share expertise. Ask a question or take a crack at answering the new questions below.

Join us:
Facebook

Twitter

Pinterest

Tumblr

LinkedIn

Google+

Ask a Question