1
I have a file that has lines file.txt
like this:
www.site.com/230207|Sophie Rundle title: Episodes|5irko3ke
www.site.com/228264|Camilla Luddington title: Balifornication|5423234
www.site.com/228592|Sarah Power title: Californication|23423423
www.site.com/229022|Ali Cobrin title: American Reunion|tgkmktgkmtg
www.site.com/190074|Eva Green title: The Dreamers|rfrrfrf
I want it to be sorted into fileSorted.txt
alphabetically by the word that comes after "title", so the result would be:
www.site.com/229022|Ali Cobrin title: American Reunion|tgkmktgkmtg
www.site.com/228592|Sarah Power title: Balifornication|23423423
www.site.com/228264|Camilla Luddington title: Californication|5423234
www.site.com/230207|Sophie Rundle title: Episodes|5irko3ke
www.site.com/190074|Eva Green title: The Dreamers|rfrrfrf
I know that we have to use the sort
command, so I tried:
sort --field-separator='title:' --key=1 file.txt > fileSorted.txt
but I got this result:
sort: multi-character tab ‘title:’
I tried to search around the internet but I couldn't' find a solution. How can I sort the file the way I want to as explained above? The file has 100K lines so performance matters.
It didn't work. – George Chalhoub – 2015-12-20T17:59:44.143
Maybe this requires --key=2 rather then --key=1 ? – davidgo – 2015-12-21T02:20:39.830
I had overlooked the -k2 while working on the delimiter (answer is already updated). – Thomas Dickey – 2015-12-21T02:23:49.483