[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Text Processing Question



Adahma <adahma@io.com> wrote:
>I have about 400 little 2 line files to create, that I'm sure should
>be scriptable, but can't seem to figure out the right tools.
>
>The file format should be as follows:
>
>DBUSER=username/password
>export DBUSER
>
>I'd like to be able to run something like:
>scriptname username password
>
>and just have a file created and saved as the user name parameter.
>
>Is this a sed or awk kinda thing?

The shell will do nicely:

#! /bin/sh -e
cat >"$1" <<EOF
DBUSER=$1/$2
export DBUSER
EOF

Error detection is left as an exercise for the reader. :) ('sh -e' is a
good start, though - the script will terminate if any command in it
returns an uncaught error.)

Cheers,

-- 
Colin Watson                                     [cjw44@flatline.org.uk]



Reply to: