Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how list two files in a single command 1

Status
Not open for further replies.

keerthi2016

Programmer
Jul 20, 2015
14
0
0
IN
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
 
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.

 
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


 
Uh, that should be...

Code:
((ls -ltr first_file_template) || (ls -ltr second_file_template)) [b][highlight #FCE94F]|[/highlight][/b] 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) [b]|[/b] sort

 
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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top