I have got a dataset like this:
manufacturer,model,year,mileage,price
plym fury 1970 73 2500
chevy malibu 1999 60 3000
ford mustang 1965 45 10000
volvo s80 1998 102 9850
ford thundbd 2003 15 10500
chevy malibu 2000 50 3500
bmw 315i 1985 115 450
honda accord 2001 30 6000
ford taurus 2004 10 17000
toyota rav4 2002 180 750
chevy impala 1985 85 1550
ford explor 2003 25 9500
I am supposed to sort the file by the manufacturer and then by the price within a manufacturer.
The book says that this command will do it:
sort -t ' ' a -k1,1 -k5
My question is that what is the difference between the command above and this command
sort -t ' ' a -k1 -k5
I checked the output of both of command alone with -k1
and -k1,1
like this
sort -t ' ' a -k1,1
sort -t ' ' a -k1
and both of them were the same, and why is it that when are adding -k5
the output in these two cases are different.
I am not able to understand the difference between -k1
and -k1,1
properly in terms of functioning,
Can anyone explain this to me with the context of the given dataset.
-k5n
instead of-k5
– Stéphane Chazelas Feb 06 '13 at 22:37