I have two csv files example


I want to make the command ls to search only the file t_test_yyyyymmdd.csv

  • 1
    Please edit your question and clarify. Do you mean you have many files with different dates? Are you just looking for ls t_test_[0-9]*? – terdon Feb 8 at 10:55
  • 1
    Thank you it works very well – rauyan_13 Feb 8 at 11:03

If you want to list all files whose name starts with t_test_ and then has a number, you can use:

ls t_test_[0-9]*

The [0-9] is a character class that matches any number, and the * means "one or more times".

  • Thank you it works very well – rauyan_13 Feb 9 at 10:40

Have you considered using the |grep command to help your ls?

For example:

ls |grep t_test_type_yyyyymmdd.csv

grep is a very powerful tool for these kind of checks; more information about the grep command here: https://www.redhat.com/sysadmin/how-to-use-grep.


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