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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell scripting problem

Status
Not open for further replies.

gfunk123

IS-IT--Management
May 22, 2001
143
GB
I have n files that are generated by a system and they will be named 'file1 file 2 file3 file4' etc. I need to concatenate these files into one file called result. The problem is that i need the data in the file4 to be at the top and the data in file1 to be at the bottom etc. (ps file4 will not always be the highest file , it could go all the way to file999)

I tried doing this

ls file* | sort -r | cat > result

but this just gives me a file with a list of the file names and not the concatenated data.

Somebody mentioned that I might need to use xargs at some point but was unable to tell me how

Any help on this would be greatly appreciated
 
ls file* | sort -r | xargs cat > wherever

is ONE way to do that.

If there are too many, you may need to do something like

ls | xargs grep "^file?" | sort -r | xargs cat > wherever

Probably a simpler way to do that but I'm in a rush :)

Tony Lawrence
SCO Unix/Linux Resources tony@pcunix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top