The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to use sed to sort out this question sonicstage Shell Programming and Scripting 2 04-07-2008 04:39 AM
SORT question ssgatbliss UNIX for Dummies Questions & Answers 2 03-22-2007 01:15 PM
Sort/Grep Question aarondesk UNIX for Dummies Questions & Answers 5 03-06-2006 05:57 PM
Sort Question bobo UNIX for Dummies Questions & Answers 7 02-24-2006 12:04 PM
Using Sort kemobyte Shell Programming and Scripting 1 11-30-2005 08:25 AM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 07-13-2007
BearCheese BearCheese is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 10
sort / cut question

Hi All,

I have a small problem, hope you can help me out here.

I have a file that contains the same format of lines in 99% of the cases.
906516 XYZ.NNN V 0000 20070711164648 userID1 userID2 hostname 20070711164641

There are unfortunately several lines with these format:
906516 XYZ V 0000 20070711164647 userID1 userID2 hostname 20070711164641

The difference is in the 2nd coloumn. Sometimes its length is 3 , sometimes 7 digits long. Thus the number of delimiters between 2nd and 3rd column are also varied. Imagine the two lines as "V" in coloumn 3 would be in the same line...


My scenario is:
cut out the 1st(the number) and 5th (timestamp) coloumn and sort the result in reverse order using the timestamp column as key.

My command is:
cat filename |cut -f 1,15 -d " " |sort -r -k 2,2

Obviously this cannot work properly because sometimes the 5th column does not start at the 15th " " delimiter due the above mentioned reasons.

Could you guys let me know a solution I can carry out this scenario? I checked man for cut but could not find an option of using sophisticated delimiters, etc...

Thanks a lot!
BearCheese
 

Bookmarks

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:01 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0