Technical professionals. Trusted advisors. Certified expertise.

  • Home
  • Support
  • Blog
  • Using the sed command to find and replace words in a file

HCS Blog

Problem-solving by Apple Certified Professionals

Using the sed command to find and replace words in a file

This is a sed command to replace the word false with true in the updates.xml document.

sed -i "" 's/false/true/' /Users/work/Desktop/updates.xml 

Here is a breakdown of the above command.


The -i will edit the file in place.

The "" will get around not having an extension after the -i as required by os x.  

You could also use sed -i.bak which would create a backup of the file before it’s edited instead of the "".

The remainder of the command:  replace “false” with “true” in the file updates.xml. 

You could add a “g” to the command to replace all instances of false with true in the updates.xml document with the command below.

sed -i "" 's/false/true/g’ /Users/work/Desktop/updates.xml

×
Stay Informed

When you subscribe to the blog, we will send you an e-mail when there are new updates on the site so you wouldn't miss them.

Using the sed command to find and replace and enti...
Create a payload free package using pkgbuild

Locations


New York

Connecticut
Florida
Louisiana
Chicago

Corporate Headquarters
New York

80 Orville Drive Suite 100
Bohemia, NY 11716
Tel: (866) 518-9672
This email address is being protected from spambots. You need JavaScript enabled to view it.

Connecticut

65 High Ridge Road #510
Stamford, CT 06905
Tel: (866) 518-9672
This email address is being protected from spambots. You need JavaScript enabled to view it.

Florida

3321 SW 194th Terrace
Miramar, FL 33029
Tel: (866) 518-9672
This email address is being protected from spambots. You need JavaScript enabled to view it.

Louisiana

218 Barksdale Drive
Broussard LA 70518
This email address is being protected from spambots. You need JavaScript enabled to view it.

Chicago

4 Knollwood Place
Joliet, IL 60433
This email address is being protected from spambots. You need JavaScript enabled to view it.

London

10 Grosvenor Court
Rayners Road
London SW15 2AX UK

Stay Connected

© Copyright 2023, HCS Technology Group. All Rights Reserved.