How Linux deletes files with spaces
This article mainly explains how Linux deletes files with spaces, the content is clear, interested friends can learn, I believe it will be helpful after reading.
People usually have more contact with documents without spaces in their work. In this way, the delete operation is relatively simple. But sometimes we come into contact with files with spaces. How should we delete this kind of file?
First, let's demonstrate the find command combined with the xargs command to delete files without spaces.
[root@ELK-chaofeng test] # touch 1.txt 2.txt [root@ELK-chaofeng test] # ls1.txt 2.txt [root@ELK-chaofeng test] # find. -type f | xargs./1.txt. / 2.txt [root@ELK-chaofeng test] # find. -type f | xargs rm-rf [root@ELK-chaofeng test] # ls [root@ELK-chaofeng test] #
Next we will show you how to delete a file with spaces.
[root@ELK-chaofeng test] # touch 1.txt 2.txt' 1 2.txt' [root@ELK-chaofeng test] # ls1 2.txt 1.txt 2.txt [root@ELK-chaofeng test] # lltotal 0kuhashi rwkashi-1 root root 0 Feb 14 12:24 1 2.txtMashi RKui-1 root root 0 Feb 14 12:24 1.txtKui RWKui [1 root root 0 Feb 14 12:24 2.txt] # find. -type f-print0 | xargs-0 rm-rf [root@ELK-chaofeng test] # ls
The above parameter-print0, compared to the default-print, the output sequence is not separated by spaces, but by null characters. Xargs also has a parameter of-0, which accepts input streams separated by null instead of spaces.
After reading the above content, do you have a further understanding of how Linux deletes files with spaces? if you want to learn more, you are welcome to follow the industry information channel.