Bash: If line begins with >
bash, if-statement
Solution
Spaces are needed inside `[[ and ]]` as follows:
if [[ "$line" == ">"* ]]; then
echo "found"
else
echo "not found"
fi
Problem
I want an `if`/`then` statement in Bash and I can't seem to get it to work. I would like to say "If the line begins with `>` character, then do this, else do something else". I have: ``` while IFS= read -r line do if [[$line == ">"*]] then echo $line'first' else echo $line'second' fi done ``` But it isn't working. I also tried to escape the ">" by saying: ``` if [[$line == ^\>*]] ``` Which didn't work either. Both ways I am getting this error: ``` line 27: [[>blah: command not found ``` Suggestions?