Hi I need to trim white spaces from strings in a file.
Input file is like this:
1_rrc_CatalogGroups.csv = 607
1_rrc_Sales_TopCatalogGroups.csv = 4
1_rrc_Sales_CatalogEntries_CatalogGroup_Rel.csv = 7
Need to trim space before and after = symbol.
This is my script:
#!/usr/bin/ksh
run_count=1
catalog_name=rrc
cd /Dataload_Scripts/Files/$catalog_name
# Getting row count from property file
FILE_NAME=$run_count"_"$catalog_name"_Record_Count.prop"
#pwd
for file in $run_count"_"*.csv; do
PROP_KEY=$file
echo "PROP_KEY "$PROP_KEY
RowCount_from_prop=`cat ${FILE_NAME} | grep "${PROP_KEY}" | cut -d'=' -f2`
echo "RowCount_from_prop= "$RowCount_from_prop
# Get row count from csv file
RowCount_from_csv=$(awk 'END { print NR-1 }' $file )
echo "RowCount_from_csv= "$RowCount_from_csv
if [ "$RowCount_from_csv" == "$RowCount_from_prop" ]
then
echo "Column header count row proper"
else
echo "Error send a mail as count is not correct in " $file
ret_flag=1
fi
done
if [ $ret_flag -eq 1 ]; then
exit 1
else
exit 0
fi
Due to spaces I'm not able to match the correct RowCount_from_prop and RowCount_from_csv. Its giving me error due to white spaces in input file.
Any help will be appreciated.
Thanks