list only identical filename

Hi Friends,

We have four filenames with first few digits are identical.From those files, i need to pick up 2 files based on my parameter.
The following example will give more information to understand my question.

Files in the directory:

small_customer_aa.csv
small_customer_ab.csv
small_customer_relate_aa.csv
small_customer_relate_ab.csv

I'll pass the small_customer as a parameter to shell script.
My expected flenames as below

small_customer_aa.csv
small_customer_ab.csv

i'have tried to use

$ls -a small_customer*.csv

but it will give all the filenames.

Thanks in advance for your valueble solutions. :stuck_out_tongue:

Regards,
HAA

How about 'ls -a small_customer_a*'?

Hi Corona

i cannot pass the parameter like 'small_customer_a',

Thanks and Regards,
HAA

How about 'ls -a small_customer_[a-z][a-z].csv' ?

Failing that, I'll need more information on what files should match and what files shouldn't since the available information is pretty sketchy.

Hi Corona

parameter=$1

if parameter is small_customer then
expected filenames:
small_customer_aa.csv
small_customer_ab.csv
else if parameter is small_customer_relate then
small_customer_relate_aa.csv
small_customer__relate_ab.csv

end if;

how can i extract the above filenames from the directory.

Hope this will clear my requirement.

Regards,
HAA

If you want only files ending _[xx].csv, you can try following

#!/bin/ksh
parameter=$1
for list in `ls ${parameter}_??.csv`
do
echo $list
done

Hi

Thanks a lot it works fine :slight_smile: :o