I have written a generic unix script to load oracle table from any csv.Now the delimeter(field seperator) in the csv can be anything like ',' or '|" or ':' etc. Hence i am trying to pass the delimeter as an argument to the script explicitly and its working fine for most of the delimeters but when i am trying to pass | then its not giving me proper result as it is implicitly converting | to ,
ksh -x myscript csv_name |
# not working
ksh -x myscript csv_name ,
# working
Please suggest me if there is in escape used for this?
Tested in my machine, you need to use below command -
ksh -x test.sh file "|"
OR
ksh -x test.sh file \|
OR
ksh -x test.sh file '|'
We need to disable the functionality of "|" using escape,single or double quotes.
Testing -
cat file
A|B|B|A
A|A|A
B|A|B|A
B|B
A|A
A|B
A|A|B
cat test.sh
vFile=$1
sep=$2
awk -F "$sep" '{print $1,$2}' ${vFile}
ksh -x test.sh file "|"
A B
A A
B A
B B
A A
A B
A A