Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - Software
User Name
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.


  Search this Thread
Old 08-19-2009, 05:38 PM   #1
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:

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


The resulting line:


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

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 07:01 PM. Reason: Solved
Old 08-21-2009, 04:13 AM   #2
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

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, 08:17 AM   #3
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
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 08:20 AM.


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

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

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration