I have shell script which generate sql queries based on a values in text file. My text file has values as follows (line by line)
my shell script is this.
#!/bin/sh
NAME="tableNames.txt"
COLUMNA="ca"
COLUMNB="cb"
cat $NAME | while read LINE
do
echo "CREATE TABLE \"$LINE\" (
forward_speed double precision,
backward_speed double precision
);"
done
LINE variable get the value from textfile correctly but it has newline character how do i remove new line character.
You probably generated the text file on a windows machine or some other setting with dos line endings. You can fix that by either
cat $FILE | tr -d '\r' | while read LINE ...
cat $FILE | awk '{print $1}' | while read LINE ...
If tabeNames.txt
is from Windows you should do a dos2unix filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With