Is it possible for an ls command to return a list of files containing "PRO" in its file name and belong to pli file type? I have researched and identified that ls -c -lt *.PLI will return a files of ".pli" type and ls -c -lt *PRO* will return file which has PRO in its file name.

Example: If the folder contains:

  • aaaaaPROaaaaa.PLI
  • aaaaaPROaaaaa.PSO
  • aaaaaPROaaaaa.txt
  • bbbbbPRObb.PLI
  • bbbbbPRObb.txt

... then I need the ls command to return only aaaaaPROaaaaa.PLI and bbbbbPRObb.PLI

If it is not achievable through the ls command, can we achieve it through the find command?

1 Answer 1


With ls, you can do:

ls -c -ltd -- *PRO*.PLI

With find:

find . ! -name . -prune -type f -name '*PRO*.PLI'

(note that find will include hidden files like .xPRO.PLI while the shell glob (*PRO*.PLI) will not by default).

  • Gnouc: It is so simple.. I thought it will be more complex :-). Thanks a lot for your quick solution. Aug 7, 2014 at 5:40
  • Out of curiosity, why prune everything rather than -maxdepth 1?
    – user60101
    Aug 11, 2014 at 4:51
  • prune is defined by POSIX, -maxdepth 1 not.
    – cuonglm
    Aug 11, 2014 at 4:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .