Hi,
I am running a small awk script to get the substring of
a string. But I am getting "invalid character in expression"
error. I played around with all single quotes and double
quotes but I could not figure it out.
Here is my script
File Name : test
-------------------------------
#!/bin/bash
echo $1
HEADER=`head -n 1 $1`
echo Header is $HEADER
HEADERDATE=`awk "BEGIN {print substr('$HEADER',1,5)}"`
echo $HEADERDATE
My Error
-------------------------------
[oracle@ODW3 unifi]$ ./test source*/wrapmainUPD.txt
sourcefiles/wrapmainUPD.txt
Header is HDR, Master Table Data, Date [9,10,2003]
awk: cmd. line:1: BEGIN {print substr('HDR, Master Table Data, Date [9,10,2003]',1,5)}
awk: cmd. line:1: ^ invalid char ''' in expression
Any help is greatly appreciated.
Thanks,
Modem