Hi All

Facing issue with using sed and globally replacing a word with date variable for a sql file.

Any help would be appreciated.

sed -e "s/DATEST\/$DATESTART/g" $SQLREAD > $SQLNEW

sed -e "s/DATEST\/08/25/2009:07:41:41/g" /uat/ut21_sysmon/quest/foglight/JJ/jjsql
Suffix too large - 512 max: s/DATEST\/08/25/2009:07:41:41/g

Thanks

Recommended Answers

All 4 Replies

sed -e "s/DATEST\/08/25/2009:07:41:41/g"
One or more of the / in your dates needs escaping.

Hi Salem

I might of not explained it properly, what i pasted was the code and the output via set -v

The code in the script is this:
[sed -e "s/DATEST\/$DATESTART/g" $SQLREAD > $SQLNEW]

Basically my variable [$DATESTART = 08/25/2009:07:41:41] for example.
I need to keep the / in my date variable due to database requirements within the sql code. Is this causing the headache with Sed or is it possible to get round this, or could you suggest any other unix power tool?

Many thanks for your advice

Use a different separator.
Eg.

sed -e "s@DATEST\@$DATESTART@g"

I can't figure out where the real separator is in the middle of the expression.
But you get the idea.

commented: i didn't know you could switch separator chars +9

Hi Salem

Thanks!! Issue resolved, appreciate the advise with the separator

[sed -e "s@DATEST@$DATESTART@g" $SQLREAD]

Output [08/26/2009:08:31:14]

Perfect for my sql file.

Many Thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.