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

hi, can I tell to "ls" to list f

hi, can I tell to "ls" to list f

(OP)

hi,
can I tell to "ls" to list files in the order they were given on the parameter list?

I mean instead of:

CODE

$ ls -al list_1 list_2 list_10
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_1
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_10
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_2 

get:

CODE

$ ls -al list_1 list_2 list_10
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_1
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_2
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_10
$ 

until now I need to sort it like:

CODE

$ ls -al list_1 list_2 list_10|sort -n -t _ -k 2,2
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_1
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_2
-rw-r--r--    1 userx  staff              0 Nov 19 19:18 list_10
$ 

can the sort (or any other extra) command be omited and use "some" embedded ls feature to achieve this?

RE: hi, can I tell to "ls" to list f

If they were created in the correct order chronologically, you can use "-tr" to sort them by time.

CODE

$ touch list_1
$ touch list_2
$ touch list_10
$ ls -l list_*
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_1
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_10
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_2
$ ls -ltr list_*
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_1
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_2
-rw-r--r--   1 userx    staff          0 Nov 21 13:36 list_10 



RE: hi, can I tell to "ls" to list f

2
On what OS? On Linux you can use ls -U to do this. I think this is a GNU extension... at least it's not available on HP-UX, I haven't looked on any other OS.

Annihilannic
tgmlify - code syntax highlighting for your tek-tips posts

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