
Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[tlug] sed / shell / redirection question
- Date: Sun, 06 May 2007 23:04:40 +0900
- From: Mark Makdad <mark@example.com>
- Subject: [tlug] sed / shell / redirection question
- User-agent: Thunderbird 1.5.0.10 (Windows/20070221)
TLUG,
I would like to write a bash script to automate the update of some
scripts I have. I made the mistake of hard-coding the pathname into
some of them (before I wised up and used a variable), and I don't want
to go through 100+ php files and update them manually.
I constructed the following sed statement:
sed 's*old/path/name*new_variable_name*' ....
But then I decided to make this into a shell script, so:
#!/bin/bash
for X in *.php
do
sed 's*old/path/name*new_variable_name*' $X > $X
done
Which seemed to work? I'm not sure, I tried many things, and when I
executed sed by itself on the shell I got the desired results. However,
I don't want to rename the files a bunch of times; I want to edit them
as-is. My question is:
Why did this take all of my input files and truncate them at zero bytes?
Am I screwing up a basic redirection thing there? And also, does anyone
have a stiff drink? I just overwrote 20 files and just lost about an
hour of work (yay backups). My mistake, though, for playing with fire
without backing up.
Cheers,
Mark
Home |
Main Index |
Thread Index