嗷嗷 大佬有话说 :
linux的文件/夹名有空格的情况下应该怎么遍历它?
Linux的数组是用空格分隔的
获取文件夹名后保存到一个数组里
遍历它,就发现把一个文件名按空格分成几个了。应该怎么解决呢?
https://developer-forum-online.cdn.bcebos.com/a50cfd7a-17e0-4aa7-b6eb-183c5004d20c.png
志明 大佬有话说 :
不知道你写的啥脚本,这是我之前的笔记,用的print0
@localhost ~]# find -name "*.txt"
./1 2.txt
./a b.txt
# find -name "*.txt" -print0
./1 2.txt./a b.txt#find -name "*.txt" -print0|xargs ls -l
xargs: WARNING: a NUL character occurred in the input.It cannot be passed through in the argument list.Did you mean to use the –null option?
ls: cannot access ‘./1’: No such file or directory
ls: cannot access ‘2.txt’: No such file or directory
ls: cannot access ‘b.txt’: No such file or directory
# find -name "*.txt" -print0|xargs -0 ls -l
-rw-r–r–. 1 root root 0 Jul 26 20:23 ‘./1 2.txt’
-rw-r–r–. 1 root root 0 Jul 26 20:23 ‘./a b.txt’
#
Developer_HZH 大佬有话说 :
试试for i in ./[MICAT* ; do echo "${i}" ; done
manc 大佬有话说 :
加引号
嗷嗷 大佬有话说 :
Developer_HZH 大佬有话说 : 2020-7-27 16:41
试试for i in ./
恐怖如斯,听君一席话,胜读十年书
嗷嗷 大佬有话说 :
志明 大佬有话说 : 2020-7-27 16:34
不知道你写的啥脚本,这是我之前的笔记,用的print0
# find -name "*.txt"
./1 2.txt
print0,学到了
我来打酱油的 大佬有话说 :
加一个 IFS=$’n’