[clug] Ever received a .dat file from an <other OS> user?
Anthony David
adavid at adavid.com.au
Fri Jan 15 07:32:36 MST 2010
Peter Barker wrote:
> On Fri, 15 Jan 2010, Adam Baxter wrote:
>
>> What do the \ ?_? wildcards do?
>
> \ is escaping the following space. The question marks stand for any
> single character. So the pattern "part\ ?_?.dat" will match:
> "part 1_1.dat"
> "part a_b.dat"
>
> See "Pattern Matching" in "man bash".
>
> While we're on shell scripting.... a question of my own.
>
> I vaguely recall a safe way of doing this:
>
> rm -rf $dir_i_do_not_want/$subdir_i_do_not_want.
>
> This is... somewhat unsafe, particularly when run by root. I *think*
> I recall a shell trick to turn this into a safe operation, so you
> *don't* do something unfortunate to your system should those variables
> be empty. Any takers?
Hi Peter
One way might be testing for non-zero length strings
[ -n "$dir_i_do_not_want" ] && [ -n "$subdir_i_do_not_want" ] && rm -rf
$dir_i_do_not_want/$subdir_i_do_not_want
Anthony
>
> Yours,
More information about the linux
mailing list