I am searching for the files with a pattern which is stored in a variable.
eg:
the day is taken from the date format into a variable "day"
I am trying to search with the pattern in that variable.
ls -ltr | grep "$day"
I am not getting the filtered output.
Please help me in how to search for the pattern which is in a variable.
I have made a little change and am getting the output but if the date is Sep 2 then if am searching for that using the variable then am getting the output as all the files which contain sep 2
eg :
Sep 23
Sep 24 etc.,
hi ...
sample input:
path ="/dir/sample" :we have the files as
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month date filename
desired output for command
cd $path
ls -ltr | grep "$day" >samplefile -----(where $day=month1 date1)
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month1 date1 filename
hi ...
sample input:
path ="/dir/sample" :we have the files as
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month date filename
abcab-a-c 1 user xxx filesize month date filename
desired output for command
cd $path
ls -ltr | grep "$day" >samplefile -----(where $day=month1 date1)
abcab-a-c 1 user xxx filesize month1 date1 filename
abcab-a-c 1 user xxx filesize month1 date1 filename