#!/bin/bash
NEW_TEXT="if failed Send to Karn Kumarl"
OLD_FILE="$(awk '{print $1}' RMANJOBS | while read JB;do autorep -j $JB -q;done | egrep "^/|^insert_job|^description" | sed '0~3 a\\')"
NEW_FILE="MRMANJOBS"
AWK='''
#.. Get new text from the shell variable.
BEGIN { NewText = " " ENVIRON["TXT"] "\042"; }
#.. If this line needs the fix, substitute the text.
/^description:.* [Ii]f failed / { sub (/ [Ii]f failed .*$/, NewText); }
#.. Print all lines, whether fixed or not.
{ print; }
'''
TXT="${NEW_TEXT}" awk "${AWK}" "${OLD_FILE}" > "${NEW_FILE}"
Guys .. can anyone help me to sort the command output into a variable .. as its not taking for OLD_FILE.
set -x
at least before the line that's giving you trouble so you can see what it looks like when the variables are all expanded, perhaps you'll spot the issue that way. – Eric Renouf Jul 27 at 18:51awk '{print $1}' RMANJOBS | while read JB;do autorep -j $JB -q;done | egrep "^/|^insert_job|^description" | sed '0~3 a\\'
command). Why you put empty lines after each 3rd? – Costas Jul 27 at 19:30