On Tuesday 13 November 2007 14:06, Chris Arnold wrote:
> So now i have a need to insert ' at the beginning of text and at the
> end in over 2000 files. The text is always the same and is always
> found on the first line of the files (there are over 2000 files). The
> text is
> ../../wp-blog-header.php and the finished text should look like
> '../../wp-blog-header.php'. How would i make a bash script to
> accomplish this or is it possible?
It's less a BASH task than it is a sed or, perhaps, Perl one.
This one's easy first go-'round:
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
targetList=(
# List files, either explicitly
one.php
two.php
foo.php
bar.php
# ... or by using command substitution based on "find":
$( find baseDir name='*.php' )
# ... or "ls":
$( ls $baseDir/*.php )
)
for target in "[EMAIL PROTECTED]"; do
sed \
--in-place=.bak \
-e "1s;../../wp-blog-header.php;'&';" \
"$target"
done
-==--==--==--==--==--==--==--==--==--==--==--==--==--==--==-
Randall Schulz
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]