Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我需要从特定文件名列出文件,直到另一个特定文件名。例如,我有 file1.txt、file2.txt、file3.txt、file4.txt、file5.txt 如果我想从 file2.txt 开始并在 file5.txt 结束,它应该列出文件名(而不是内容)file2 .txt、file3.txt、file4.txt 和 file5.txt。有没有办法使用 head 和 tail 来做到这一点,如果没有,有什么好方法可以做到这一点?
ls | sort -n | sed '/file2/,/file5/!d'
ls -l | sort -n | grep -B1000 "file5.txt"