Solved

How to replace characters using sed?

Posted on 2011-03-18
2
322 Views
Last Modified: 2012-05-11
Dear experts,

I have many files containing a line as below:

GPEHDownloadAll = "0"

I want to change this line in these files to:

GPEHDownloadAll = "0" ----> GPEHDownloadAll = "1"  (zeros will be one)

Note: Be careful of spaces between equal sign.

Can you help me using sed for this?

BR,
0
Comment
Question by:GurcanK
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 125 total points
ID: 35165173
sed  's/GPEHDownloadAll = "0"/GPEHDownloadAll = "1"/' inputfile

Or is there not always the same number of spaces?

wmp
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 35165220
Sorry, I just saw "many files"

grep -l 'GPEHDownloadAll = "0"' * | xargs -I{} sed  -i 's/GPEHDownloadAll = "0"/GPEHDownloadAll = "1"/' {}

Attention - the above will change the files "in place"!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A year or so back I was asked to have a play with MongoDB; within half an hour I had downloaded (http://www.mongodb.org/downloads),  installed and started the daemon, and had a console window open. After an hour or two of playing at the command …
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question