Reputation: 3611
Does tilde character need to be escaped in bash script?
I have tried to escape it with \~ but it does not help. If I remove the ~ character, the code below works as expected.
if ! [[ "$line" =~ ^[0-9a-zA-Z-~]+$ ]]; then
echo "skipping .. $line"
continue
fi
How do I add the tilde character in the above expression?
Upvotes: 4
Views: 1409