Reputation: 39
i have script like this below : testing.sh
#!/bin/bash
while read inputline
do
plugin="$(echo $inputline | cut -d, -f 3-)"
echo \"$plugin\" > test1.out
done < $1
exit 0
config file : test.conf
host1-192.168.31.200,Current_Users,check_users -w 20 -c 50
after execute the script :
#./testing.sh test.conf
the output file : test1.out
"check_users -w 20 -c 50^M"
How to prevent/avoid the ^M
?
Upvotes: 0
Views: 266
Reputation: 7698
The easiest way is probably to edit your test.conf file to remove it (did it come from another OS?). However, you can also use tr to get rid of it:
plugin="$(echo $inputline | tr -d \\r | cut -d, -f 3-)"
Upvotes: 1