Dvaderanakin
Programmer
How do awk recognize user input such as "Record (1)"??
I have a script that search an inputed fields by the user. The script search the fields and display what's in between the entered fields.
Sample data:-
Record (1) "ML_REC"
"REC_SEQ_NUMBER" = "000442"
"CALL_ID" = "00000000"
"REC_NUMBER" = "01"
"CAUSE_FOR_OUTPUT" = "04"
"A_IMSI" = "234159006266939F"
"A_IMEI" = ""
"CALLING_NUM" = "11447810816136"
"CALLED_NUM" = "120414207193"
"CELL_1ST" = "05F54000015DCB"
"CELL_LAST" = "05F54000015DCB"
"TIME_CHANNEL" = "122525"
"FAULT_CODE" = ""
"TELE_CODE" = "11"
"BEARER_CODE" = ""
"CHAN_RATE_INFO" = "01"
"TRANS_IND" = ""
"RF_POWER_A" = "04"
"DTMF" = ""
"SS_CODE" = ""
"CUG_INTERLOCK" = ""
"CUG_INDEX" = ""
"CUG_OUT_ACC_USED" = ""
"CUG_OUT_ACC_IND" = ""
"REG_SERV_USED" = ""
"REG_DEP_CO" = ""
"CHARG_CASE" = "0001"
"DATE" = "020723"
"TIME_CHARGE" = "122531"
"DURATION" = "0005"
"B_CAT" = "00"
"CALL_STAT" = "03"
"ABNRML_REL" = "01"
"TARIFF_CLASS" = "01"
"TARIFF_ACT_CODE" = "01020D"
"A_CAT" = "01"
"OUT_ROUTE" = "535346494E2020"
"EXCHANGE_ID" = "4D4F444D53432F4134382F30305830"
"MSC_ID" = "1161415019900F"
"MISC_INFO" = ""
"ORIG_FOR_CHARGE" = "15"
"CAMEL_SERVER_ADDRESS" = "1144385016450F"
"CAMEL_SERVICE_LEVEL" = "0F"
"CAMEL_SERVICE_KEY" = "00000006"
"CAMEL_CALL_REFERENCE" = "11614150199000005C103E7F"
"CAMEL_DESTINATION" = "120414209999"
"CAMEL_MODIFICATION" = "5F"
"INTERNAL_CAUSE_AND_LOC" = "0003"
End of Record (1)
How to make the awk command recognize "Record (1)" and End of Record (1)"???
The output should display whatever in between.
Part of my script:-
echo "Please enter a field name:"
read FILE1
file1=$1
awk '$1 ~ /'"$FILE1"'/' $DIR > tmp
echo "What do you want to do?"
echo "Do you want to display the contents?"
echo "Please enter y/n only"
read ANS
if test "$ANS" = "y"
then
vi tmp
else
echo "You could see your results in ~/tmp"
echo "Searching is done!!"
echo "Please wait for a few second to return to main menu"
sleep 1
fi
I have a script that search an inputed fields by the user. The script search the fields and display what's in between the entered fields.
Sample data:-
Record (1) "ML_REC"
"REC_SEQ_NUMBER" = "000442"
"CALL_ID" = "00000000"
"REC_NUMBER" = "01"
"CAUSE_FOR_OUTPUT" = "04"
"A_IMSI" = "234159006266939F"
"A_IMEI" = ""
"CALLING_NUM" = "11447810816136"
"CALLED_NUM" = "120414207193"
"CELL_1ST" = "05F54000015DCB"
"CELL_LAST" = "05F54000015DCB"
"TIME_CHANNEL" = "122525"
"FAULT_CODE" = ""
"TELE_CODE" = "11"
"BEARER_CODE" = ""
"CHAN_RATE_INFO" = "01"
"TRANS_IND" = ""
"RF_POWER_A" = "04"
"DTMF" = ""
"SS_CODE" = ""
"CUG_INTERLOCK" = ""
"CUG_INDEX" = ""
"CUG_OUT_ACC_USED" = ""
"CUG_OUT_ACC_IND" = ""
"REG_SERV_USED" = ""
"REG_DEP_CO" = ""
"CHARG_CASE" = "0001"
"DATE" = "020723"
"TIME_CHARGE" = "122531"
"DURATION" = "0005"
"B_CAT" = "00"
"CALL_STAT" = "03"
"ABNRML_REL" = "01"
"TARIFF_CLASS" = "01"
"TARIFF_ACT_CODE" = "01020D"
"A_CAT" = "01"
"OUT_ROUTE" = "535346494E2020"
"EXCHANGE_ID" = "4D4F444D53432F4134382F30305830"
"MSC_ID" = "1161415019900F"
"MISC_INFO" = ""
"ORIG_FOR_CHARGE" = "15"
"CAMEL_SERVER_ADDRESS" = "1144385016450F"
"CAMEL_SERVICE_LEVEL" = "0F"
"CAMEL_SERVICE_KEY" = "00000006"
"CAMEL_CALL_REFERENCE" = "11614150199000005C103E7F"
"CAMEL_DESTINATION" = "120414209999"
"CAMEL_MODIFICATION" = "5F"
"INTERNAL_CAUSE_AND_LOC" = "0003"
End of Record (1)
How to make the awk command recognize "Record (1)" and End of Record (1)"???
The output should display whatever in between.
Part of my script:-
echo "Please enter a field name:"
read FILE1
file1=$1
awk '$1 ~ /'"$FILE1"'/' $DIR > tmp
echo "What do you want to do?"
echo "Do you want to display the contents?"
echo "Please enter y/n only"
read ANS
if test "$ANS" = "y"
then
vi tmp
else
echo "You could see your results in ~/tmp"
echo "Searching is done!!"
echo "Please wait for a few second to return to main menu"
sleep 1
fi