How to list only files (not path) in directory with .pl extension

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • starlight849
    New Member
    • Jun 2009
    • 82

    How to list only files (not path) in directory with .pl extension

    Hi, I'm trying to list files in a different directory based on a specific criteria.
    The directory is in Dir1 and I'm in HOME.
    I would like to only list files that end in .pl

    However, I do not want to include the file path in the result.

    In short, I want to ls Dir1 but only list file names that end in .pl.


    Any suggestions?
  • sicarie
    Recognized Expert Specialist
    • Nov 2006
    • 4677

    #2
    Move into the directory first, then list

    Code:
    cd Dir1; ls *.pl
    Last edited by sicarie; Apr 5 '13, 04:04 AM. Reason: Dir has capital D according to OP's post

    Comment

    • Nepomuk
      Recognized Expert Specialist
      • Aug 2007
      • 3111

      #3
      You can automatically move back to the previous directory with the following line of commands:
      Code:
      PWD_old=`pwd`; cd Dir1; ls *.pl; cd $PWD_old

      Comment

      Working...