Hi All,
I have a file, let's call it "info.tmp" that contains data like this ..
ABC123456
PCX333445
BCD789833
I need to read "info.tmp" and for each line add strings in a way that the final output is
put /logs/ua/dummy.trigger 'AAA00001.FTP.XXX.BLA03A01.xxxxxx(+1)'
where XXX are the first three characters of each line in "info.tmp" and
xxxxxx are the remaining 6 characters of each line in "info.tmp"
So something like ...
GRP="ABC"
SITE="123456"
echo "put /logs/ua/dummy.trigger 'AAA00001.FTP."$GRP".BLA03A01."$SITE"(+1)'" >> trigger.tmp
But considering that I need this line created for each row in "info.tmp" file!
I've tried with
for GRP in `cat info.tmp | cut -c1-3`
do
for SITE in `cat info.tmp | cut -c4-9`
{
echo "put /logs/ua/dummy.trigger 'AAA00001.FTP."$GRP".BLA03A01."$SITE"(+1)'" >> trigger.tmp
}
done
but of course this duplicates records ... because for each GRP it matches every SITE.
I've also tried
awk '{print substr($0,1,3)}'
awk '{print substr($0,4,9)}
but I don't know how to "concatenate" this result with the other "echoes" I need and I know that after an awk is used, if you use another one, you won't have the full string you had at the first time. Also if I "echo" then the "awk" would take that string and not the content of the file "info.tmp".
Help will be much appreciated!