#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    1
    Rep Power
    0

    Bash: list only certain files


    Hi

    I think I have a temporary lapse of reason...

    I cant figure out how to list only files that have only 7 digits in their names and all end in .txt.

    like 7654321.txt or 4532123.txt

    I don't want to list files that have not exactly y digits in their name.

    I tried:

    ls [0-9]{7}.txt

    but it doesn't work

    ls [0-9]*.txt

    works but returns of course any number of digits in the file name (not what I want)


    Please advise.

    Thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    830
    Rep Power
    496
    Try this:

    Code:
    ls -l | perl -ne 'print if / [0-9]{7}\.txt$/;'
    Last edited by Laurent_R; February 7th, 2013 at 01:10 PM.

IMN logo majestic logo spyfu logo threadwatch logo seochat tools logo