LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-13-2008, 06:27 PM   #1
hk20
LQ Newbie
 
Registered: Sep 2007
Posts: 4

Rep: Reputation: 0
sed/grep new lines in text


Hello,

How do you stop sed or grep from putting a string on a new line?
I am working with a text file, and it is treating my spaces as newlines.

ex:
cat blah.txt | sed /\"/s/\"//g

INPUT:

"This is a test"
"Test1"
"Test2"


output:

This
is
a
test
Test1
Test2


Thanks
 
Old 09-13-2008, 06:34 PM   #2
Mr. C.
Senior Member
 
Registered: Jun 2008
Posts: 2,529

Rep: Reputation: 63
I'm not seeing results you see:

Code:
$ cat in
"This is a test"
"Test1"
"Test2"
$  sed /\"/s/\"//g in
This is a test
Test1
Test2
Note that I replaced your useless use of cat; nearly all utilities can read files specified as command line arguments.

Code:
$  sed 's/"//g' in 
This is a test
Test1
Test2
Note that I removed the addressing portion (/\"/) as it is unnecessary in your case. No substitution could occur unless the line contains a double quote anyway, right? Also, it is more common to use single quotes to quote the entire sed expression, as it makes reading the expression clearer.
 
Old 09-13-2008, 06:47 PM   #3
hk20
LQ Newbie
 
Registered: Sep 2007
Posts: 4

Original Poster
Rep: Reputation: 0
Thank You for the pointer, I will do some reading up on sed.
 
  


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 or grep : delete lines containing matching text raj000 Linux - General 18 09-08-2012 09:38 AM
Delete specific Range of lines Using sed , awk, grep etc. joyds219 Linux - Newbie 4 03-28-2008 08:59 AM
Replacing text on specific lines with sed or awk? Lantzvillian Linux - Newbie 5 10-17-2007 09:00 AM
awk/sed to grep the text ahpin Linux - Software 3 10-17-2007 12:34 AM
Simple Text Reformat (sed and grep) mikefazz Programming 2 08-31-2004 07:38 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

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