The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
need help cutting consecutive lines with sed or awk raghin Shell Programming and Scripting 2 06-04-2008 01:59 AM
Cutting specific lines from a file pathanjalireddy Shell Programming and Scripting 6 06-02-2005 06:45 AM
Cutting n consecutive lines from a file... Vishnu UNIX for Dummies Questions & Answers 2 10-18-2002 07:49 AM
max charachters for usernames m.szylkarski UNIX for Dummies Questions & Answers 1 02-01-2002 07:50 AM
Cutting lines out using sed I presume. cfoxwell UNIX for Dummies Questions & Answers 5 01-07-2002 08:13 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 08-02-2005
Registered User
 

Join Date: May 2005
Location: Mount Blanchard
Posts: 9
Stumble this Post!
Cutting the top two lines, and also charachters below.

Hey all. I have a file that I am trying to cut information out of. We have a script that shows us all of our Radio Scanners that are being used and I'm writing a script that clears all of the context off of the scanners. The script that runs shows us this information below...

|emp_id |first_name|last_name |base_unit|radio_id|
|---------|----------|--------------------|---------|--------|
|S990CA2 |CORY |AUKERMAN | 1| 66|
|S990LR4 |LARRY |ROGERS | 1| 67|
|S990EF1 |ELIZABETH |FREDRITZ | 1| 69|
|S990JG7 |JARED |GEORGE | 1| 70|
|S990SM9 |SANTOS |MELCHOR JR. | 1| 71|
|S990RB8 |RONNIE |BOWLIN | 1| 73|
|S990MW3 |MEGAN |WARE | 1| 74|
|S990ML1 |MICHAEL |LOWERY | 1| 75|
|S990HW2 |HAMER |WOLFE | 1| 77|
|S990RB13 |RAY |BYERLY | 1| 81|
|S990DM3 |DEAN |MULVAINE | 1| 82|
|S990JH3 |JAY |HARTMAN | 1| 84|

The only info that I need are emp_id and the Radio_id. The only problem is, I don't know how to cut the top 2 or 3 lines to erase the headers. I have the characters that I need cut out just fine, but I'm not so sure about the top 2 lines. Any help would be great.

Thanks a lot.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 08-02-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,449
Stumble this Post!
try:
sed '1,2d'
Reply With Quote
  #3 (permalink)  
Old 08-02-2005
Registered User
 

Join Date: May 2005
Location: Mount Blanchard
Posts: 9
Stumble this Post!
It doesn't appear to be working. Do I need to put the filename behind it, or pipe the line to the sed command? Can you be a little more detailed?
Reply With Quote
  #4 (permalink)  
Old 08-02-2005
vgersh99's Avatar
Moderator
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 3,002
Stumble this Post!
sed '1,2d' filename | theRestOfTheFieldCuttingLogic
Reply With Quote
  #5 (permalink)  
Old 08-02-2005
Registered User
 

Join Date: Jan 2005
Posts: 682
Stumble this Post!
Yes, "sed" needs an input. This is a basic requirement of all such utilities. sed can take its input from stdin or from referencing a file.

Example 1:
Code:
cmd | cmd | cmd | sed '1,2d'
Note: "cmd" is simply some scripting command or a UNIX utility.
Example 2:
Code:
sed '1,2d' your_really_big_file
Quote:
It doesn't appear to be working.
This is because sed is expecting keyboard entries. Try it again and enter a bunch of lines and when you press CTRL-D on your keyboard, you'll see the expected results: all lines except the top two will be reprinted on your screen.
Reply With Quote
  #6 (permalink)  
Old 08-02-2005
Registered User
 

Join Date: May 2005
Location: Mount Blanchard
Posts: 9
Stumble this Post!
That did it. I was just running radiousers.log sed 1,2d instead of piping it. Thanks for the help everyone. You saved the day again.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 08:51 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0