LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 08-07-2017, 05:42 AM   #16
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018

Even when you use sort, there are tricks you can use to maintain the input order.

Code:
test@ws1:/tmp$ cat input.txt 
4 ZZZ
1 ABC
1 DEF
1 MNO
2 PQR
2 UVW
3 XYZ
4 CCC
test@ws1:/tmp$ cat -n input.txt | sort -u -k 2,2 | sort -k 1n | cut -f2
4 ZZZ
1 ABC
2 PQR
3 XYZ
test@ws1:/tmp$
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
data manipulation in linux: how to make columns from rows in linux Rozak Linux - Newbie 3 09-12-2015 02:07 AM
[SOLVED] Switch to instance instead of creating a new instance of a program javascriptninja Linux - Newbie 8 01-28-2012 03:39 PM
How to convert 1 column into several rows in Linux? markraem Linux - Software 9 03-30-2010 11:24 AM
Compare two fields on consecutive rows and print the two rows aditi_borkar Linux - Newbie 3 04-09-2009 05:49 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration