简体   繁体   中英

xarg, find and rm rm: cannot remove `./not': No such file or directory

I am following this Wikipedia example to find and remove a file.

[jalal@galapagos-04] (5)$ touch 'not important_file'
[jalal@galapagos-04] (6)$ touch important_file
[jalal@galapagos-04] (7)$ ls
agreement.txt    cs_web          johns.txt            reverse_sorted_user.txt  songs.txt        users.txt*
awk_example.txt  good_users.txt  marks.txt            sed_example.txt          sorted_user.txt
cs.html          important_file  not\ important_file  softlink/                test@
[jalal@galapagos-04] (8)$ find . -name not\* | tail -1 | xargs rm
rm: cannot remove `./not': No such file or directory

Any idea how could this be fixed?

The xargs article you link to discusses in detail how using null or line-terminated processing is needed to handle these exact situations, but you're not even using xargs .

You've copied an example that's mean to illustrate something that doesn't work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM