Hi ,
I'm looking for some code that can copy and paste form file1 to file2 with 2 criterial meet.
file1:
test "sp-j1"
test "sp-j2"
test "sp-j3"
test "sp-j4"
file2:
sub Pre_Shorts1 (Status_Code, Message$)
global Status
!if Message$ <> "" then print tab(5);Message$
!Status = Status_Code
subend
sub Pre_Shorts2 (Status_Code, Message$)
global Status
!if Message$ <> "" then print tab(5);Message$
!Status = Status_Code
subend
output expected:
sub Pre_Shorts1 (Status_Code, Message$)
global Status
if Message$ <> "" then print tab(5);Message$
Status = Status_Code
test "sp-j1"
test "sp-j2"
test "sp-j3"
test "sp-j4"
call Update_Status (Status_Code, All_Failed)
subend
sub Pre_Shorts2 (Status_Code, Message$)
global Status
!if Message$ <> "" then print tab(5);Message$
!Status = Status_Code
subend
currently using code is.
var=$(grep -n "sub Pre_Shorts1" testplan_temp| cut -d : -f 1)
line=$((var+4))
#echo $line
sed -e "${line}r file1" file2 >outputfile
it still working, if the line number always same.
some of my file might have some difference, if i have file like, and i'm need insert after call Panel_Enable_Boards
sub Pre_Shorts1 (Status_Code, Message$)
global All_Failed
global BoardSet_boards_1_to_4(*)
! if Message$ <> "" then print tab(5);Message$
! call Panel_Enable_Boards
! call Update_Status (Status_Code, All_Failed)
subend