Solved

How to replace characters using sed?

Posted on 2011-03-18
2
321 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
  • 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

Suggested Solutions

Title # Comments Views Activity
Where to get php 5.6 for AIX 7.1? 5 118
Solaris 4.1.3 cloning and booting 13 84
add some character at the end of line in vi 7 92
Perl script to process a .csv file 18 45
When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

828 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