1

I have bunch of files in one directory. I want to list specific files within this directory whose name as follows;

stacov_abcd0230.15o
stacov_abcd0240.15o
stacov_ab120240.15o
stacov_01020240.15o

There are always 8 characters string after stacov_ and .[0-9][0-9]o is the file format all the time.

The other files have also stacov_ prefix but the lenght of the following strings are different than above file names like;

stacov_abcd_pre
result_stacov_abcd

How can I use ls command to view the relevant files?

1

If you want to be absolutely precise:

ls stacov_????????.[0-9][0-9]o

in shell globbing ? indicates any single character.

0
ls stacov_[0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z][0-9a-z].[0-9][0-9]o 
0

The easier command for this is:

ls stacov_*.*o

But if the * after . are strictly numbers, then, you can use:

ls stacov_*.[0-9][0-9]o

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.