列出特定目录中特定类型的文件 [英] List files of particular type from a specific directory

查看:63
本文介绍了列出特定目录中特定类型的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从特定目录列出特定类型的文件?例如我想列出/home/ABC/files/目录中的所有* .csv文件,而我现在位于/home目录中.

How to list particular type of files from a specific directory? e.g. I want to list all *.csv files from /home/ABC/files/ directory and I am in /home directory right now.

推荐答案

TMTOWTDI .

(cd /home/ABC/files/; ls *.csv)
ls /home/ABC/files/*.csv | sed 's:.*/::'
ls /home/ABC/files/*.csv | xargs -n1 basename
ls /home/ABC/files/*.csv | rev | cut -d/ -f1 | rev
for i in /home/ABC/files/*.csv; do echo "${i##*/}"; done

这篇关于列出特定目录中特定类型的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆