×
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!
  • Students Click Here

*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.

Students Click Here

Jobs

how list two files in a single command

how list two files in a single command

how list two files in a single command

(OP)
how to list the two files using the number.

i have tried the below command and it doesn't work.

CODE

ls -ltr  *TYSON.250.*.*27718* \*17717* 

CODE

Projections.TYSON.250.US.FOOD.ALL.SAUDIT.37717.W1955_W1955.meta
Projections.TYSON.230.US.FOOD.ALL.SAUDIT.37717.W1955_W1955.meta
Releasibility.TYSON.250.US.FOOD.ALL.SAUDIT.37718.W1687_W1955.meta
Releasibility.TYSON.230.US.FOOD.ALL.SAUDIT.37718.W1687_W1955.meta
Releasibility.TYSON.250.US.FOOD.ALL.SAUDIT.47718.W1687_W1955.meta
Releasibility.TYSON.250.US.FOOD.ALL.SAUDIT.47717.W1687_W1955.meta 

RE: how list two files in a single command

It's not clear exactly what you're trying to do. Which two files are you trying to list?

Your list of file names doesn't include either "27718" or "17717", so there should be no match with what you've given.

A couple ideas...

CODE

ls -ltr *TYSON.250.*.meta | egrep "27718|17717"

# or

ls -ltr *TYSON.250.*.27718.*.meta *TYSON.250.*.17717.*.meta

# or

ls -ltr *TYSON.250.*.[12]771[78].*.meta

# but that would also include "17718" and "27717" if they exist. 

RE: how list two files in a single command

here's another idea:
((ls -ltr first_file_template) || (ls -ltr second_file_template)) > sort (optional)

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


RE: how list two files in a single command

Uh, that should be...

CODE

((ls -ltr first_file_template) || (ls -ltr second_file_template)) | sort 

The '>' will create a file named 'sort'. You need to pipe it to sort ('|').

The logical 'and' (&&) is needed to list both files. Using a logical 'or' (||), it won't list the second file if the first file is found. Of course using 'and', it won't list either file if the first one isn't there.

This would be more concise...

CODE

(ls -ltr first_file_template ; ls -ltr second_file_template) | sort 

RE: how list two files in a single command

yes, after I posted I realized that sort has a mandatory parameter for file name, thus pipe.
as for the ||, I screwed up thinking that the double pipe was the concatenate command (as it is in SQL).

Thanks to SamBones for the ocrrections.

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


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! Already a Member? Login

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