Finding files with the name of the results of another search

Dear All,
I have a file with this name= xx-nnnn.csv , I has texts in this format,

231048975938093056;234317862284705793;609384034;14955353;1344700706000;1;
231048975938093056;234317958632054785;715450794;52422878;1344700729000;1;
231048975938093056;234317958632054785;715450794;14955353;1344700729000;1;
231048975938093056;234318551647924227;32599342;52422878;1344700870000;1;
231048975938093056;234319048949780482;252168241;14955353;1344700989000;2;

now I want to take take all the second fields as the search parameter, and find the files with files names containing this

for example all the files with *234317862284705793*.csv or *234317958632054785.csv

Thank u in advance.

best,
David

Is the file named xx-nnnn.csv in the same directory as the files with names like *234317862284705793*.csv and *234317958632054785.csv ? Why do you need an asterisk after the numbers found in the 2nd field in xx-nnnn.csv for the data on the 1st line of the file, but do not need one for the data on the 2nd and 3rd lines in the file? Why is the data on other lines in that file ignored?

After you find the names, what do you want to do with them?

1 Like

Thank you so much,
yes in the same directory, we just assume * , actually all the files have the same pattern, important is to have these numbers containing in the file name.
it is for every line, it was just an example.
just show the file names.thank u so much

What is the environment?

1 Like

Ubuntu 14, 64bit , Terminal

You could try something like:

#!/bin/ksh
while IFS=";" read junk x junk
do      ls -1 *$x*.csv 2> /dev/null
done < xx-nnnn.csv

The ls command option is the digit one; not the lower case letter ell.

In addition to working with ksh , this will also work with any other shell that accepts basic Bourne shell syntax.

1 Like

Thank you so much, but it doesnt work.
To test, I inserted the filename of one of the files in another file and tested as below:

#!/bin/ksh
while IFS=";" read junk x junk
do ls -1 *$x*.csv 2> /dev/null
done < cascs-233250026925740032.csv

there is no output.

now in cascs-233250026925740032.csv , we have one line with the filename of another file in this dir.

In your earlier posts, you said you had a CSV file named cascs-233250026925740032.csv that contained data in the format shown in the 1st message in this thread. Why (instead of putting your data in that file as you showed us) did you decide to put the name of a file in that file? Put the data in the file instead of the name of a file and try it again!

1 Like

Thank you so much, sorry I should be more precise, I actually meant data, or number.
for example I created casc-43564.csv file and put the record,
1;43564;1 in the file cascs-233250026925740032.csv but however it doesnt work-

Please show us the output from the commands:

ls *43564* | od -bc

and

od -bc cascs-233250026925740032.csv
1 Like

Thank you so much, sorry yes you are right, it was my mistake.it works.