Solved

How to replace characters using sed?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
I have been running these systems for a few years now and I am just very happy with them.   I just wanted to share the manual that I have created for upgrades and other things.  Oooh yes! FreeBSD makes me happy (as a server), no maintenance and I al…
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now