LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
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 10-14-2009, 09:51 AM   #1
docetes
LQ Newbie
 
Registered: Jun 2005
Posts: 12

Rep: Reputation: 0
Awk string question


Code:
echo this is a \"test\" string | awk '{gsub(/\"test\"/,"", $0);print$0 }'
It just doesn't feel like the best way of doing it and it can take a few minutes to complete on largish files

Thanks,
Dave
 
Old 10-14-2009, 09:58 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
Arghhhhh.. My EYES!!! lol...

How about:
Code:
echo this is a \"test\" string | sed -e 's/"test"//'
 
Old 10-14-2009, 10:03 AM   #3
docetes
LQ Newbie
 
Registered: Jun 2005
Posts: 12

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by rizhun View Post
Arghhhhh.. My EYES!!! lol...

How about:
Code:
echo this is a \"test\" string | sed -e 's/"test"//'
Thanks for the quick response but if i do the following

Code:
echo this is a \"test\" string this is a \"test\" string  | sed -e 's/"test"//'

it will only remove the first "Test"
 
Old 10-14-2009, 10:14 AM   #4
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
Add the global flag to sed (little 'g'):

Code:
echo this is a \"test\" string this is a \"test\" string  | sed -e 's/"test"//g'
 
  


Reply

Tags
awk


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
Append to string in awk Zmyrgel Programming 2 09-20-2009 08:50 AM
[awk] Metacharacters in string constant Pico1 Programming 4 04-26-2009 05:06 PM
add String in awk an_sush Linux - Newbie 1 11-20-2008 11:42 AM
Excluding a string in awk when printing szahri Programming 2 03-22-2007 03:00 AM
string concatenation in AWK xanthium Programming 1 04-22-2002 05:41 AM


All times are GMT -5. The time now is 02:35 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration