LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 08-19-2009, 04:38 PM   #1
musonio
Member
 
Registered: Jun 2009
Distribution: PCLinuxOS
Posts: 33

Rep: Reputation: 15
Question about sed syntax in bash script


I have a small problem with the syntax of sed in a script.
I just want it to search for a string in a specific file and replace only a part of the string.

Line in the script:

Code:
sed s/NAME="*"/NAME=John/ names.txt > names2.txt
The line I want to modify:

NAME=Peter

The resulting line:

NAME=JohnPeter

Alternative lines I have tried without success:
Code:
sed s/"NAME="*""/NAME="John"/ names.txt > names2.txt
Code:
sed s/"NAME="*""/"NAME=John"/ names.txt > names2.txt
Any ideas?

SOLVED:
I hadn't noticed that I missed a "." in ".*". Now it works.
I'm new to this forum so I don't know how to remove the post. Sorry.

Last edited by musonio; 08-19-2009 at 06:01 PM. Reason: Solved
 
Old 08-21-2009, 03:13 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 988
Blog Entries: 4

Rep: Reputation: 254Reputation: 254Reputation: 254
Greetingz!

Glad to hear you found a solution! No worries, and if you ever need help, just drop another post on us!

On a side note, if you can provide a sample of the file you're parsing (it doesn't have to be an *exact* sample, no need to post anything sensitive), it'll help us out.

Good luck on your code!
 
Old 08-21-2009, 07:17 AM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
I'm new to this forum so I don't know how to remove the post.
Don't!! What you did was fine---or you could simply reply with what you found.

Also---mark the thread as solved---which I have just done.

and Welcome to LQ!!

Last edited by pixellany; 08-21-2009 at 07:20 AM.
 
  


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
Another SED Syntax Question... stlouis Programming 3 01-17-2008 08:50 PM
SED in BASH Script - Syntax Problem stlouis Programming 4 01-13-2008 10:38 AM
Bash script syntax error snowman81 Programming 5 11-16-2007 02:35 AM
How to check the bash script syntax? mesh2005 Linux - General 2 04-23-2006 08:22 AM
help with basic syntax in bash script Supp0rtLinux Linux - Software 4 03-27-2003 06:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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