Hi World,
I am extracting text from an ebcdic header using dd in the cygwin environment (bash/ksh) as below in order to rename the file to something intelligent.
I'm using a specific string position here ($10) but the text I extract is sometimes in a different position in the header so I need to search for preceding text "LINE:" and then extract the next string, which is the info I'm interested in.
So - using awk or sed (or perl if need be) can anyone help me with the syntax for
'find string 'LINE:' and return next string'
Secondly, in order to avoid overwriting files I'm appending a -1, -2, -3 etc but doing a specific search for this.
In awk, how does one read a filename, check to see if there's a -x at the end, and if so, split that off and increment it by one for naming the next file.
Thanks for any tips,
Bryan.
for file in s*.00* ;
do
dd if=$file of=header conv=ascii count=1
linename=`awk '{print $10}' header`
if [ ! -e $linename".sgy" ] ; then
cp $file $linename".sgy"
elif [ -e $linename".sgy" ] && [ ! -e $linename"-1.sgy" ] ; then
cp $file $linename"-1.sgy"
etc until $linename"-4.sgy"
done