Reputation: 136
In a bash script, I use a $temp
variable containing several lines of text and I need to remove the first character in all the lines that start with a space.
I tried using sed:
temp=$(sed 's/ //' <<< "$temp")
but it removes the first space no matter where it is, so I end up with some words altogether.
Upvotes: 0
Views: 330
Reputation: 41460
Try this then:
temp=$(sed 's/^ //' <<< "$temp")
It will anchor the space to beginning of the line.
Upvotes: 2