help me for i command

Discussion in 'HOWTO-Related Questions' started by aspangilinan, Nov 5, 2011.

  1. aspangilinan

    aspangilinan New Member

    hi to all,

    i have little problem, anyone can help me,
    when i run script. the message

    here's the script.

    find /home/samba/shares/accounting_group -name *.tmp > /root/accounting_tmp3.txt;
    for i in `cat /root/accounting_tmp3.txt`;
    do rm $i;
    done

    the error.

    rm: cannot remove `/home/samba/shares/accounting_group/OLD': No such file or directory
    rm: cannot remove `Hardisk': No such file or directory
    rm: cannot remove `2005-2008/Loida/~WRL0699.tmp': No such file or directory
    rm: cannot remove `/home/samba/shares/accounting_group/OLD': No such file or directory
    rm: cannot remove `Hardisk': No such file or directory
    rm: cannot remove `2005-2008/Loida/~WRL0005.tmp': No such file or directory


    [email protected]:/root# find /home/samba/shares/accounting_group -name *.tmp

    but still existing the *.tmp file. and i want to delete are files.

    /home/samba/shares/accounting_group/OLD Hardisk 2005-2008/Loida/~WRL0699.tmp
    /home/samba/shares/accounting_group/OLD Hardisk 2005-2008/Loida/~WRL0005.tmp




    Can you help me, help help.

    thanks
    ARnel
     
  2. jmerken

    jmerken New Member

    shell command

    I would use xargs for this>>

    you need the option -print0 due to spaces in the directory and again the xargs -0 option to be able to work with the spaces when executing the rm command

    e.g.

    find /home/samba/shares/accounting_group/OLD Hardisk 2005-2008/Loida/ -iname '*.tmp' -print0 | xargs -0 /bin/rm -f

    good luck :)
    Jan
     
  3. aspangilinan

    aspangilinan New Member


    Thanks thanks Jan,

    i hope next time you can help me again.
    thanks
     

Share This Page