Skip to main content
10 events
when toggle format what by license comment
Aug 7, 2017 at 8:53 history edited Stéphane Chazelas CC BY-SA 3.0
added 33 characters in body
Nov 15, 2016 at 6:19 comment added Wildcard @KeithThompson, any shell will handle file globbing correctly, not only Bash, and rm never does any form of word splitting whether it's GNU rm or not. The shell expands the globs and, when it executes the command called for, it passes in the resulting filenames as null separated arguments (in the C code). What's dangerous is to pipe a list of files to something which uses newlines as delimiters; see Why is looping over find's output bad practice?
Dec 17, 2015 at 18:54 comment added Justsalt Since the file name is only one character instead of rm -i -- *, you could do rm -i -- ?, then only have to evaluate the files with single-character names.
Jan 13, 2012 at 22:52 history edited Gilles 'SO- stop being evil' CC BY-SA 3.0
added -- in case a file in the directory has a file name beginning with a -
Jan 13, 2012 at 20:29 comment added Keith Thompson @ChristofferHammarström: There's a newline in the expanded name because the file name contains newline characters. But it seems I've underestimated bash and GNU rm. On my system, rm *, rm -i *, and rm Ctrl-V DEL TAB ENTER all work correctly, even if the file name contains a newline character (I used "\177foo\nbar\n"). Some commands don't handle such file names well, but the GNU tools seem robust; non-GNU versions of the same tools might not behave as well. In any case, the various tricks in these answers are useful to know.
Jan 13, 2012 at 19:05 comment added Keith Thompson @ChristofferHammarström: Hmm. I'll do some experiments and comment further.
Jan 13, 2012 at 11:25 comment added Christoffer Hammarström @KeithThompson: Glob expansion in the shell isn't subject to further interpretation. There wouldn't be a newline in the expanded name unless it contained one.
Jan 13, 2012 at 5:32 comment added Keith Thompson I suspect that rm -i * wouldn't have worked in this case; because of the newlines, the shell would expand * to something that rm wouldn't recognize as the file name.
Jan 13, 2012 at 3:15 vote accept Mr Moose
Jan 13, 2012 at 1:57 history answered antje-m CC BY-SA 3.0