eHow launches Android app: Get the best of eHow on the go.

How To

How to Replace a String Command Line

Contributor
By Kristen Leigh Grubb
eHow Contributing Writer
(0 Ratings)

Sed is a command line tool that is installed by default on Unix and Linux operating systems and available for download for the Windows operating system. Sed is used to filter text which means text is provided as input, and the utility performs the operations required and the modified text is provided as output. It is typically used for pattern matching or string substitution. Sed can use literal strings or regular expressions in the pattern matching or substitution.

Difficulty: Easy
Instructions

Things You'll Need:

  • Sed
  1. Step 1

    Open a terminal window. A terminal window will provide a command prompt where you will type the following commands.

  2. Step 2

    Navigate to the directory where your files that you want to edit are located.

  3. Step 3

    Type "sed 's/search/replace/g' *.txt" to replace all the instances of the string "search" with the string "replace" in "file.txt."

  4. Step 4

    Open the files in a text editor to check that the string has been replaced.

  5. Step 5

    Type "exit" to close the terminal session.

Tips & Warnings
  • A version of sed is available for the Windows operating system (see Resources)
Resources
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy .   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License. † requires javascript

eHow Computers
eHow_eHow Technology and Electronics