I'm working on a autosys job which create a new file and insert filenames into that it. Currently im using below command which works based on the filename pattern. Unfortunatly this command is pulling wrong files with similar file name. So i wanted to create a command which will insert hardocded data into the file.
Current Logic:
find /home/temp/ -maxdepth 1 -name '*_File_Data.csv' -printf '%f\n' > /home/temp/File_Data.txt
Current Output:
abcd_File_Data.csv
is not supposed to be selected.
$ cat File_Data.txt
a_File_Data.csv
b_File_Data.csv
c_File_Data.csv
d_File_Data.csv
abcd_File_Data.csv
Expected Output:
abcd_File_Data.csv
was not selected.
$ cat File_Data.txt
a_File_Data.csv
b_File_Data.csv
c_File_Data.csv
d_File_Data.csv
Please let me know how to achive this scenario. Thanks in advance!!
Thank you all for your inputs on this question.
Tried using the below command and it worked as expected:
find /home/temp/{a_File_Data.csv,b_File_Data.csv,c_File_Data.csv,d_File_Data.csv} |xargs -n 1 basename > /home/temp/File_Data.txt
Not sure if i have to use "-maxdepth 1" in my command but the above command worked even there are similar file names in the sub directories.