Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to replace characters using sed?

Posted on 2011-03-18
2
Medium Priority
?
324 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 500 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

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…
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

704 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