当前位置: 技术问答>linux和unix
取某一路径下的类似文件名(50)
来源: 互联网 发布时间:2015-05-15
本文导语: 取某一路径下的类似文件名(50) 例: ls /opt/share/*.CSV 结果: /opt/share/TM_Denpyou_99_20010807.CSV /opt/share/TM_Denpyou_99_20030707.CSV /opt/share/TM_Denpyou_99_20020807.CSV /opt/share/TM_Denpyou_99_20030807.CSV /opt/share/TM_Denpyou_99_20030303.CSV ...
取某一路径下的类似文件名(50)
例:
ls /opt/share/*.CSV
结果:
/opt/share/TM_Denpyou_99_20010807.CSV
/opt/share/TM_Denpyou_99_20030707.CSV
/opt/share/TM_Denpyou_99_20020807.CSV
/opt/share/TM_Denpyou_99_20030807.CSV
/opt/share/TM_Denpyou_99_20030303.CSV
但我不想要路径,只要文件名,怎么办?
例:
ls /opt/share/*.CSV
结果:
/opt/share/TM_Denpyou_99_20010807.CSV
/opt/share/TM_Denpyou_99_20030707.CSV
/opt/share/TM_Denpyou_99_20020807.CSV
/opt/share/TM_Denpyou_99_20030807.CSV
/opt/share/TM_Denpyou_99_20030303.CSV
但我不想要路径,只要文件名,怎么办?
|
用sed或awk过滤ls的输出:
ls /opt/share/*.CSV | sed 's/.*/(.*CSV)/1/'
ls /opt/share/*.CSV | sed 's/.*/(.*CSV)/1/'
|
find /opt/share -name "*.CSV" -exec basename {} ;