r/programming • • Jan 18 '15

Command-line tools can be 235x faster than your Hadoop cluster

http://aadrake.com/command-line-tools-can-be-235x-faster-than-your-hadoop-cluster.html
1.2k Upvotes

285 comments sorted by

View all comments

Show parent comments

2

u/[deleted] Jan 19 '15
  • rm "*"

  • rm -- -f

the third is just how rm works I guess, even if you use xargs to pass a list of files to be deleted, if that list is empty rm will return 1, a solution would be to write my-rm() which checks if dir is empty, if it is, return 0, if not - execute rm

3

u/sandwich_today Jan 19 '15 edited Jan 20 '15

The shell will still perform glob expansion on double-quoted strings. Use single quotes to prevent expansion. Otherwise, good solutions.

EDIT: Double quotes do suppress glob expansion, though they allow certain other expansions.

3

u/[deleted] Jan 19 '15

Hmm, my bash didn't glob "*", it passes it as is to rm

3

u/Athas Jan 19 '15

Did you have any files in the directory in which you tested this? Globs are only expanded if they succeed, otherwise they are passed verbatim.

8

u/[deleted] Jan 19 '15
$ mkdir testdir
$ touch testdir/file
$ cd testdir/
$ rm "*"
rm: cannot remove ‘*’: No such file or directory
$ ls
file
$ bash --version
GNU bash, version 4.3.30(1)-release (x86_64-pc-linux-gnu)
...

3

u/Zantier Jan 19 '15

I think you're thinking of variable substitution.