INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

ksh, matching any n digits

ksh, matching any n digits

(OP)

I can do list a 3 digits files in that way:

ls -ld [0-9][0-9][0-9]


but following with number doesn't work (example for longer name files):

ls -ld {15}[0-9]





RE: ksh, matching any n digits

If I understand your problem correctly (i.e. looking for files which have a specific length and consist only of numbers) this would be a possible solution - in this example desired length is 4 characters

$ ls
1 1234 2 23456 3456 45 45678 567 bl23 bluh
12 12345 234 3 34567 456 5 5678 blah
123 1bla 2345 345 4 4567 56 56789 bloh
$ find /home/tom/Dokumente -type d -regextype posix-egrep -regex ".*/[^/][0-9]{3}"
/home/mrjazz/Dokumente/5678
/home/mrjazz/Dokumente/4567
/home/mrjazz/Dokumente/2345
/home/mrjazz/Dokumente/3456
/home/mrjazz/Dokumente/1234

so files blah, bloh, bluh, and also 1bla, bl12 are not found

RE: ksh, matching any n digits

(OP)
hello

I have a solution which is fine for me:
ls|grep -E '^[[:digit:]]{15}$'


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close