Quote:
Originally Posted by
itkamaraj
where is my echo statement in the output?
what shell you are using ?
echo $SHELL
/bin/bash
Code 1:
echo $delimiter_char
if [ $delimiter_char eq "TAB" ]
then
echo "Inside the TAB condition"
col_cnt=`echo $header_line | awk -F'/t' '{print NF}'`
else
echo "Coming here for TAB?"
col_cnt=`echo $header_line | awk -F"$delimiter_char" '{print NF}'`
fi
Output 1:
./get_col_lengths.sh CUSTOMER.dat 'TAB'
TAB
./get_col_lengths.sh: line 21: [: eq: binary operator expected
Coming here for TAB?
No. of Records in CUSTOMER.dat : 200
No. of Columns in CUSTOMER.dat : 1
Code 2:
echo $delimiter_char
if [ $delimiter_char = "TAB" ]
then
echo "Inside the TAB condition"
col_cnt=`echo $header_line | awk -F'/t' '{print NF}'`
else
echo "Coming here for TAB?"
col_cnt=`echo $header_line | awk -F"$delimiter_char" '{print NF}'`
fi
Output 2:
./get_col_lengths.sh CUSTOMER.dat 'TAB'
TAB
Inside the TAB condition
No. of Records in CUSTOMER.dat : 200
No. of Columns in CUSTOMER.dat : 1