TechDex Development & Solutions
live minder, lead generation, trend analysis, market research, internet marketing, seo, social media, keyword analysis


RSS Feed| Blog Home | Log In | View As Guest  | Archives |

Blog Search

Search and Replace Strings with Grep in UNIX

Search and Replace Strings with Grep in UNIX
Posted by Dexter Nelson: Tuesday, May 6, 2014 (2:39 PM)

How To Search And Replace Strings With Grep (UNIX Commands)


As a programmer and marketer, when I create tools (like a member center), often times I just copy whole directories to save time. It's smart, since I don't want to re-write code from scratch every time.


I also don't want to have to spend hours editing every single file, especially if it has tons of them.


So I use grep to search and replace strings in every file in a directory.


Here is the UNIX Command format.


# grep -rl / | xargs sed -i 's///g';


I'm writing it this way for a few reasons, namely it's the easiest format to follow, and I've seen some crazy ways of doing this. I prefer the pipe because it saves on having to backslash comment special characters (I think).


Below is an image from a new site that I set up.


I have several subdomains (one for each tool) and you can see how it looks in real life.


search and replace strings with grep in UNIX

Admin
User: Admin 
Member Since: 1/1/2009 
Number of Posts: 143 
Message Admin
--
Dexter Nelson
TechDex Development & Solutions
http://www.techdex.net

Facebook: http://www.facebook.com/dexter.nelson
Twitter: http://twitter.com/dexterwebn

Leave A Reply


Post A Comment


Most Commented Stories
  1. Windows Media Player Crashes Playing MP4 Files (Solved) (662)
  2. Saggy Pants Cost Green Day Singer His Plane Seat (183)
  3. Ounce By Ounce Gold Takes Off (166)
  4. Occupy Protesters Rally Around Wounded Iraq Vet (82)
  5. SOLVED EXE Files Wont Run Cant Run EXE Files (30)
  6. TechDex SMART Mobile Design (21)
  7. Live Minder Case Study 1 (18)
  8. TechDex DirectToDesktop direct2client technology (16)
  9. Updated How To Get Indexed in Yahoo (14)
  10. Live Minder Trend Analysis Statistics Day 4 (13)

Top 10 Stories
  1. How to Increase the WordPress Maximum Upload File Size
  2. Apple Claims Their New iPad Pro Will Replace The Laptop
  3. Secunia PSI 3.0 Stuck on Determining Which Files to Scan SOLVED
  4. How To Successfully Remove Rombertik Malware
  5. Using Dark Post Profits 2.0 To Increase Software Sales
  6. Best Free Ad Blocking Software Review
  7. Free Commercial Real Estate Service And Real Estate Script
  8. Are Earthquakes Causing Global Climate Change
  9. Understanding What Caused The Border Crisis
  10. AT&T trumps Google with first gigabit internet in Raleigh




® Live Minder © TechDex Development & Solutions.
live minder, lead generation, trend analysis, market research, internet marketing, seo, social media, keyword analysis

Powered by TechDex CGI Blog.