I have files with name
145345000_abcd_20211201
100045430_abcd_20211130
143240000_abcd_20211129
in this (_abcd_)
remains constant rest of the numbers in beginning and timestamp at the end changes every day.
i want to list all such files in a txt file
I am doing the following
ls ${mypath}/ > ${mypath}/my_list.txt
this will list all files and folder in mypath where I want only file with (abcd) in file name please guide. I Have tried many combinations already
CodePudding user response:
Use grep
to filter the files with abcd
like this:
ls ${mypath}/ | grep abcd > ${mypath}/my_list.txt
Alternatively, you can use ls
only like this:
ls -1 ${mypath}/*abcd* > ${mypath}/my_list.txt