- Forums
- Linux Hosting
- Search And Replace Word In Linux
This Post Will Show You A Simple Command You Can Send In The Linux Shell To Search And Replace A Text Using Awk [1333], Last Updated: Mon Jun 24, 2024
Webune Tutorials
Mon Feb 01, 2010
0 Comments
441 Visits
Welcome to Webune
Webune provides Linux Dedicated servers. If you are tired of your current hosting provider, please consider Webune.
Today's short tutorial is about searching and replacing certain keywords or words for example in a file using awk in linux.
the command is pretty straight forward, lets say i have a file called hosting.php and this is how hosting.php looks like:
Webune has great Web Hosting Service - Please visit www.webune.com to get started with a dedicate linux server today.
as you can see hosting.php is pretty simple - so lets say we want to change the word 'Service' with 'Support' we can use this shell command to do exactly that:
awk '{gsub("Service", "Support", $0); print > FILENAME}' hosting.php
now when you open hosting.php it will look like this:
Webune has great Web Hosting Support - Please visit www.webune.com to get started with a dedicate linux server today.
IMPORTANT: its very important to mention that Linux is case sensative, so Support and support are not the same
hope that helps