I have problem with running my simple shell script, where I am using while loop to read text file and trying to check condition with matching regexp:
#!/bin/sh
regex="^sometext"
cat input.txt |
{
while read string
do if [[ $string ~= $regex ]]; then
echo "$string" | awk '{print $1}' >> output.txt
else
echo "$string" >> outfile.txt
fi
done
}
but I recieve only errors like
[[: not found
could you please advise me?