tree 显示
...
? ??? template_one_file.sh
? ??? template_sed.sh
? ??? testy.sh
? ??? tmp
? ? ??? file1.html.13567_old
? ? ??? file2.html.13567_old
? ? ??? file3.html.13567_old
? ? ??? file4.html.13567_old
? ??? use_case_to_add_etc_2_numbers
??? vi
??? vim_tips_and_chearsheet
??? vi_stuff
160 directories, 713 files
Run Code Online (Sandbox Code Playgroud)
我可以忽略 tmp 目录(例如) tree -I 'tmp' -L 4
...
? ??? template_multiple_files.sh
? ??? template_one_file.sh
? ??? template_sed.sh
? ??? testy.sh
? ??? use_case_to_add_etc_2_numbers
??? vi
??? vim_tips_and_chearsheet
??? vi_stuff
157 directories, 709 files
Run Code Online (Sandbox Code Playgroud)
但是为什么我不能忽略单个文件,例如_old带有
tree -I 'old' -L 4
Run Code Online (Sandbox Code Playgroud)
它仍然显示了_old文件
...
? ??? template_multiple_files.sh
? ??? template_one_file.sh
? ??? template_sed.sh
? ??? testy.sh
? ??? tmp
? ? ??? file1.html.13567_old
? ? ??? file2.html.13567_old
? ? ??? file3.html.13567_old
? ? ??? file4.html.13567_old
? ??? use_case_to_add_etc_2_numbers
??? vi
??? vim_tips_and_chearsheet
??? vi_stuff
160 directories, 713 files
Run Code Online (Sandbox Code Playgroud)
我试过'.*old'和'.*old$'模式,但这没有帮助。
使用通配符:
tree -I '*_old' -L 4
Run Code Online (Sandbox Code Playgroud)
参考:man tree(我的重点)
-I 模式
不要列出那些与通配符模式匹配的文件。