Search code examples
linuxcommand-linels

List files based on multiple search criteria


I'd like to search a directory listing for all files that either start with JL or NL, and only return those results.

I know I can do a ls -lrt JL* or an ls -lrt NL* but I need to know how to combine those in one statement.


Solution

  • How about ls -lrt JL* NL*?

    The pattern is expanded by the shell, so it tastes exactly the same to ls.

    If you're using bash you could also ls -lrt [JN]L* to create a single pattern that does what you want.