LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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-11-2003, 05:18 PM   #1
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
help with sed


I have data coming in on a serial port, I need to remove the first part of each line.

the lines look like this...

~081 Continuity Error; SAR: 6418 Line: 119 Station: 566
~090 Time Start of Retrieval AUG 04 2003 12:24::48.83
~034 Time Break: .60msec
~031 Number of Vibs: 2 Vibs Stacked: Yes


lets say they range from ~000 to ~999


I can remove them independantly with this...

sed -e 's/^~081//'


what syntax can be used to remove any code ~??? at the beginning of the line

thanks,

Last edited by DavidPhillips; 08-11-2003 at 05:22 PM.
 
Old 08-11-2003, 05:34 PM   #2
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
How about:
Code:
sed 's/^~...//'
 
Old 08-11-2003, 05:37 PM   #3
crabboy
Senior Member
 
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
Quote:
lets say they range from ~000 to ~999
If the numbers are important:
Code:
sed 's/^~[0-9][0-9][0-9]//'
 
Old 08-11-2003, 05:46 PM   #4
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Original Poster
Rep: Reputation: 58
thanks,

looks like exactly what I need
 
  


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
sed and escaping & in something like: echo $y | sed 's/&/_/g' prx Programming 7 02-04-2005 12:00 AM
Sed q? ky-lab_rat Linux - Software 5 10-26-2004 08:59 AM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 07:12 AM
Help with sed odious1 Linux - General 2 08-29-2003 11:52 AM
sed.... BongFish Linux - Software 4 08-07-2003 10:24 AM

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

All times are GMT -5. The time now is 10:19 AM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration