Pages

Wednesday, January 7, 2015

perl, bat and cygwyn by example

=====================================
General
=====================================
Launch bat file
The bat file is calling perl program via cygwin.
The perl file is just replacing tabs with ',' and renames file from txt to csv.

=====================================
convertTXT2CSV.bat
=====================================
d:\software\cygwin\bin\bash.exe --login "/cygdrive/d/path/on d drive/convertTXT2CSV.sh"

=====================================
convertTXT2CSV.sh
=====================================
#!/bin/bash
cd "/cygdrive/d/path/on d drive/"
#===================================================================
export REP_NAME="My Report One - Weekly"
echo Handling $REP_NAME
sed "s/\t/,/g"  "${REP_NAME}.txt" > "${REP_NAME}.csv"
rm "${REP_NAME}.txt"
#===================================================================
export REP_NAME="My Report Two - Weekly"
echo Handling $REP_NAME
sed "s/\t/,/g"  "${REP_NAME}.txt" > "${REP_NAME}.csv"
rm "${REP_NAME}.txt"
#===================================================================

No comments:

Post a Comment