[techtalk] Stumped by shell script

Nancy Corbett nancy at netleaf.com
Mon May 28 16:31:41 EST 2001


This is off topic, but I'm hoping your sharp eyes will see what I am
obviously missing.

I'm writing a ksh script which I want to give 3 variables and read them
from standard input.  To do this, I'm using sed.  I want sed to
change every instance of DATE to the current date in a given file
and rename the file to a different directory. 

Here's my script:

#!/bin/ksh 

sed 's/DATE/"$1"/g' "$2" > "$3"
exit 0;

Here's the format of my input file:

`date +%m-%d-%Y'
FILE.05_24_2001.0529.CSV
/path/to/newfile/FILE.`date+%H.%m_%d_%Y.%H%M`.CSV

And here's how I'm invoking it:

script < input.txt

The output is:
Can't Open

I've tried 

script < "input.txt"

I've tried not quoting $2 and $3, and it just echos input.txt to the
screen. 

I know this is something simple, but I'm stuck.  What am I doing wrong?
Nancy






More information about the Techtalk mailing list