[Cialug] find and replace strig in all files within a folder
Todd Walton
tdwalton at gmail.com
Thu Jun 7 21:08:58 CDT 2012
On Thu, Jun 7, 2012 at 7:35 PM, <afan at afan.net> wrote:
>
> hi,
> what would be the easiest but most simplest way to find and replace string
> "foo" with "bar" in all files within a folder (and all sub-folders)?
>
> [...]
>
> when tried
> $find ./ -name "*.php" -exec sed -i
> "s/\$_SESSION['status']/\$_SESSION['value']/g" {} \;
> didn't do anything
Perhaps it's seeing the brackets as denoting a list of characters.
>From the sed manual:
[list]
[^list]
Matches any single character in list: for example, [aeiou] matches all
vowels. A list may include sequences like char1-char2, which matches
any character between (inclusive) char1 and char2.
A leading ^ reverses the meaning of list, so that it matches any
single character not in list. To include ] in the list, make it the
first character (after the ^ if needed), to include - in the list,
make it the first or last; to include ^ put it after the first
character.
The characters $, *, ., [, and \ are normally not special within list.
For example, [\*] matches either ‘\’ or ‘*’, because the \ is not
special here. However, strings like [.ch.], [=a=], and [:space:] are
special within list and represent collating symbols, equivalence
classes, and character classes, respectively, and [ is therefore
special within list when it is followed by ., =, or :. Also, when not
in POSIXLY_CORRECT mode, special escapes like \n and \t are recognized
within list. See Escapes.
--
Todd
More information about the Cialug
mailing list