April 2011

duanestubbs's picture

Find and Replace within Files

Find and Replace text in files from the command line
Search through all the files and sub-folders (remove R from -RIZ to just do current directory) and replace text within files.

grep -RlZ {search text in files} . \ | xargs -0 -l  sed -i -e 's/{find}/{replace}/'

Example:

Red Hat in Farnborough

Red Hat, Farnborough

Directions

Red Hat's offices are located on the Farnborough Business Park.

Address is: Red Hat Europe, 200 Fowler Avenue, Farnborough Business Park, Farnborough, Hampshire, GU14 7JP

When on Fowler Avenue, look for the large hangar structure. There are two buildings next to it and Red Hat is the one nearest to Fowler Avenue. You can park in front of it - the entrance is round the side, facing the other building.

Tags: