Reputation: 2758
I am looking at this script
sed -i \ -e "s/^cluster_name.*/cluster_name: ${cluster_name}/g" \
How is pattern space determined with ^ at the beginning and $ at the end? Why do I need them?
Upvotes: 1
Views: 190
Reputation: 59
^ and $ are regex operators. I am not aware of how these operators are implemented. But you need to use them when you want exact match from beginning of line or at the end of line.
e.g.
Line1: This is line one.
-> starts with 'space' and ends with '.'
Line2:This is dummy Line One
->starts with 'T' and ends with 'e' characters.
if I am using regex as "^T.*e$" then it will match to line2. Please refer more information
Upvotes: 2