LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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 05-28-2009, 12:53 AM   #16
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170

Your sed command does not work for me with GNU sed
Code:
line='Tue May 26 00:00:05 CDT 2009|217|authenticate|jds'
echo "$line" | sed 's/\|jds//g'
Tue May 26 00:00:05 CDT 2009|217|authenticate|
# '|' has been left on the end of the line

# Removing the g switch makes it worse.
echo "$line" | sed 's/\|jds//'
Tue May 26 00:00:05 CDT 2009|217|authenticate|jds

# This works
# Escaping is unnecessary to get a literal '|' in a basic regex
echo "$line" | sed 's/|jds//'
Tue May 26 00:00:05 CDT 2009|217|authenticate
 
Old 05-28-2009, 10:13 AM   #17
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
You may want to look at the before & after versions of your sed output with a hex editor or od. Depending on where the logs were created, there may be end-of-line issues which are made invisible by some tools, but to which other tools are sensitive. Look especially for combinations of LF & CR.
--- rod.
 
  


Reply



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
Replacing text in multiple files ? centosfan Linux - General 10 09-20-2008 07:25 AM
Replacing text on specific lines with sed or awk? Lantzvillian Linux - Newbie 5 10-17-2007 09:00 AM
Messing with sed, need some info on changing text in files MasterC Linux - Software 1 07-27-2007 06:12 PM
sed with large text files? apollyonus Linux - Server 3 03-22-2007 07:33 AM

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

All times are GMT -5. The time now is 06:49 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