这里有一些文件,我使用python模块pysftp复制到这个linux盒中:
[jm@spartan tf]$ ls -la
total 0
drwxrwxrwx. 3 jm jm 69 Aug 14 13:50 .
drwxrwxrwt. 9 root root 238 Aug 14 13:49 ..
-rwxrwxrwx. 1 jm jm 0 Aug 14 13:49 .\gitkeep
drwxrwxrwx. 2 jm jm 6 Aug 14 13:50 .\innerfile
-rwxrwxrwx. 1 jm jm 0 Aug 14 13:50 .\inner
我想用shell脚本打印一个文件夹的结构。所以它看起来就像这样
File : linux -3.14/COPYING
File : linux -3.14/CREDITS
Directory : linux -3.14/Documentation
File : linux -3.14/Documentation/00 - INDEX
Directory : linux -3.14/Documentation/ABI
File : linux -3.14/Documentation/ABI/README
这是我的脚本。问题是它会打印出当前目录的所有
这些是我的样本文件
user@linux:~$ ls -l | cut -d ' ' -f 10-
01. old Name.txt
02. old Name.txt
03. old Name.txt
test.txt
user@linux:~$
这就是我想做的。
user@linux:~$ for output in *'old Name'*; do echo $output; done
01. old Name.txt
02. old Name.txt
03. old Name.txt
user@linux:~$
因为实际的代码多次使用old Name