List files of particular type from a specific directory
How to list particular type of files from a specific dire开发者_开发技巧ctory? 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
ls ABC/files/*.csv
ls /home/ABC/files/*.csv
echo ABC/files/*.csv
echo /home/ABC/files/*.csv
using for loop
for file in ABC/files/*.csv
do
# further processing
done
and of course, the ever useful find.(GNU)
find ABC/file -type f -iname "*.csv" -printf "%f\n"
ls ABC/files/*.csv
ls /home/ABC/files/*.csv
精彩评论