UNIX Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOperating SystemsUNIX Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old September 15th, 2004, 02:00 PM
AVS AVS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 37 AVS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 52 sec
Reputation Power: 4
sort excluding first line [heading line]

Hi,

My data file has a header line as the first line. I want to do a sort on this file but header line being retained as it is. Any direct way of doing this?

Of course I can do
head -1 dummy.txt > sort_dummy.txt
tail +2 dummy.txt | sort -u >> sort_dummy.txt

But is there a more drect way of doing this [May be any sort option, etc]

Thanks,
Sunil

Reply With Quote
  #2  
Old September 16th, 2004, 04:39 AM
guggach guggach is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2004
Location: Middle Europa
Posts: 1,083 guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level)guggach User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 4 Days 19 h 47 m 32 sec
Reputation Power: 9
NO, what you could do, open the ouput file ONCE
note the brakets!
Code:
  (  head -1 ${in:=dummy.txt} ; tail +2 $in | sort -u  )>  sort_$in


in vi, you can say
Code:
   :2,$!sort -u


and you can start vi in not interactive mode

Last edited by guggach : September 16th, 2004 at 04:41 AM. Reason: typo

Reply With Quote
  #3  
Old September 22nd, 2004, 10:48 AM
AVS AVS is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 37 AVS User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 4 m 52 sec
Reputation Power: 4
optimized thanks

Reply With Quote
Reply

Viewing: Dev Shed ForumsOperating SystemsUNIX Help > sort excluding first line [heading line]


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway