Re: Sort across two or more files
- From: pk <pk@xxxxxxxxxx>
- Date: Thu, 30 Oct 2008 19:12:51 +0100
On Thursday 30 October 2008 18:54, Quis custodiet ipsos custodes wrote:
OK, let's say we have three files: names, phone and age
[me@work /] cat names
Adam
Bob
Clare
[me@work /] cat phone
1234567
2345671
3456781
[me@work /] cat age
25
21
23
[me@work /] sort -n age
21
23
25
I now want to maintain the references between Names/Phone numbers/Ages
so that I don't end up just shuffling the data. (i.e. the Names file
gets changed to Bob-Clare-Adam, ditto the phone numbers file)
How do I accomplish this?
You might be ok with just
paste age names phone | sort -n -k1,1 | \
awk '{print $1>"age.new";print $2>"names.new";print $3>"phone.new"}
mv age.new age
mv names.new names
mv phone.new phone
.
- Follow-Ups:
- Re: Sort across two or more files
- From: Quis custodiet ipsos custodes
- Re: Sort across two or more files
- References:
- Sort across two or more files
- From: Quis custodiet ipsos custodes
- Sort across two or more files
- Prev by Date: Sort across two or more files
- Next by Date: Re: Sort across two or more files
- Previous by thread: Sort across two or more files
- Next by thread: Re: Sort across two or more files
- Index(es):