0

I want Shell script to find my Orignal_literal and change it with dynamic literal, this literal would be runtime input to script.

Eje
  • 354
  • 4
  • 8
Gautam
  • 31
  • 1
  • 4

1 Answers1

0

sed -i "s/Orignal_literal/c \\$variable/g" file.txt

Explanation:

  • sed = Stream Editor
  • -i = In-place (i.e. save back to the original file)
  • The command string:
    • s: The substitute command
    • Orignal_literal: A regular expression describing the word to replace (or just the word itself)
    • g: Global (i.e. replace all and not just the first occurrence)
    • variable: Runtime variable
    • file.txt: The file name
Eje
  • 354
  • 4
  • 8
Gautam
  • 31
  • 1
  • 4