How can I replace a line that starts with "string1" with "string2 lala" using Bash script?
Thanks in advance
How can I replace a line that starts with "string1" with "string2 lala" using Bash script?
Thanks in advance
using bash,
#!/bin/bash
file="myfile"
while read -r line
do
case "$line" in
string1* ) line="string2 lala"
esac
echo "$line"
done <"$file" > temp
mv temp $file
using awk
awk '/^string1/{$0="string2 lala"}1' file