PDA

View Full Version : i thought it wasn't loaded


jbroder
02-04-2000, 05:00 PM
Somehow (thru bad scripting) I ended up with some files
named $bend.shtml, $back.shtml, etc.

So I typed in: rm $b*

to get rid of them all.

Oops. Every file in my directory disappeared.

Luckily, the subdirectories weren't affected.

Obviously, $ has some special significance in the shell. What does $ mean in a shell context?

Next I will go read the postings on making backups...

Thanks,
Jon

// * that was a load bang * \\

Terra
02-04-2000, 05:39 PM
Yikes, definitely not good...

$b* in the shell is just a standard variable...

when you typed rm $b*, the shell expanded it to:
rm *

since $b == NULL or Undefined

What you were looking for was:

rm \$b*

This would tell bash to interpret the '$' as a literal, instead of a variable identifier...

--
Terra
--a lesson hard learned, is often a new ability not easily forgotten--
FutureQuest
[This message has been edited by ccTech (edited 02-04-00@4:40 pm)]

ChrisH
02-04-2000, 05:46 PM
[nbsp][nbsp]What I learned from such mistakes is that I often
try a

ls <whatever>

first. That shows you what the shell thinks the
<whatever> means. Then type

rm !*

and you'll remove whatever the ls listed, and you
have very little chance of making a typo since you
don't retype the <whatever>. This is C shell, but
I think bash is the same.

Of course, usually I just blast away . . .

[nbsp][nbsp]ch

Carol-H
02-09-2000, 01:47 AM
My Unix training was quite explicit: ALWAYS use &quot;-i&quot; in remove commands!

rm -i &amp;b*

would have prompted you before each remove...it's a pain when you're getting rid of a lot of files, but's it's sure safe...

- Carol Hanson
[nbsp][nbsp]www.dragonbear.com (http://www.dragonbear.com)