Re: rm - Arguments too long

From: Jan Reilink (digiover_at_dsinet.org)
Date: 04/26/03

  • Next message: Richard L. Hamilton: "Re: rm - Arguments too long"
    Date: Sat, 26 Apr 2003 10:37:08 +0200
    
    

    [f'up to comp.unix.misc set, this might go way OT]

    K Stahl wrote:
    > Jan Reilink wrote:

    [...]
    >>I haven't seen this answer (yet), it might take a while though:
    >>$ cd <directory>
    >>$ ls -1 | while read line; do (/bin/rm $line); done
    >>
    >
    >
    > What happens if there is an embedded space in a file name?
    >

    I've never thought about this, it has never happend in _my_ situations... ;)
    But thanks, it's wise to keep that in mind.

    $ touch "embedded space"
    $ ls -1 | while read line; do (/bin/rm $line); done
    /bin/rm: cannot remove `embedded': No such file or directory
    /bin/rm: cannot remove `space': No such file or directory

    $ ls -1 | while read line; do (/bin/rm "$line"); done
    does work.

    > Why not just:
    >
    > while read Buff;do /bin/rm "$Buff";done<$(ls -1);

    $ touch "embedded space"
    $ while read Buff;do /bin/rm "$Buff";done<$(ls -1);
    bash: $(ls -1): ambiguous redirect

    Regards, Jan
    (no Unix user/admin, but Debian GNU/Linux, even I am OT in this group :)

    -- 
    Dutch Security Information Network
    http://www.dsinet.org/
    

  • Next message: Richard L. Hamilton: "Re: rm - Arguments too long"

    Relevant Pages

    • Re: rm - Arguments too long
      ... Jan Reilink wrote: ... > K Stahl wrote: ... >> What happens if there is an embedded space in a file name? ... it's wise to keep that in mind. ...
      (comp.unix.misc)
    • Re: rm - Arguments too long
      ... K Stahl wrote: ... > Jan Reilink wrote: ... > What happens if there is an embedded space in a file name? ... (no Unix user/admin, but Debian GNU/Linux, even I am OT in this group:) ...
      (comp.unix.solaris)
    • Re: rm - Arguments too long
      ... K Stahl wrote: ... > Jan Reilink wrote: ... > What happens if there is an embedded space in a file name? ... (no Unix user/admin, but Debian GNU/Linux, even I am OT in this group:) ...
      (comp.unix.admin)