Hi I am trying to convert this source file:
source --------
[ODBC Data Sources]
C334_DEV_MD=Micro ODBC Driver for SQL Server Wire Protocol
C334_PRD_ST=Micro ODBC Driver for SQL Server Wire Protocol
[ODBC]
Trace=0
TraceFile=odbctrace.out
TraceDll=/home/mstr/Micro/install/lib32/MYtrcXX.so
InstallDir=/home/mstr/Micro/install
IANAAppCodePage=106
UseCursorLib=0
[C334_DEV_MD]
HostName=C334WM01NA02
PortNumber=1433
Database=C334_DEV_MD
DoubleToStringPrecision=17
[C334_PRD_ST]
HostName=C334WM01NA02
PortNumber=1433
Database=C334_PRD_ST
DoubleToStringPrecision=17
source----------
Into this file with a script.
destination--------
C334_DEV_MD=Driver description|HostName=C334WM01NA02;PortNumber=1433;Database=C334_DEV_MD;DoubleToStringPrecision=17|na01liwp01c334
C334_PRD_ST=Driver description|HostName=C334WM01NA02;PortNumber=1433;Database=C334_PRD_ST;DoubleToStringPrecision=17|na01liwp01c334
destination---------
ODBC entry is not important here.
This is a pattern the output should follow.
DSN_entry=Driver Description|Parameter1=value;Parameter2=value;Parameter3=value|Server_Name
Servername could be taken from file name of the source file.
This is what I did so far, but I am stuck.
#!/bin/bash
flag=0
sourcefile=$1
destfile=$2
sed -n '2,/^$/p' $sourcefile | awk -F"=" '{print$1}' | sed '$d' | \
while read line; do
#echo $line
grep -E ''"^${line}"'|'"^\[${line}"'' $sourcefile
done