sed 's/the/THE/' mytext.txt > new.txt
sed 's/the/THE/g' mytext.txt > new.txt
# when it occurs 2nd time in every line
sed 's/the/THE/2' mytext.txt > new.txt
# other delimiter
sed 's;half;1/2;' mytext.txt > new.txt
/a.c/ matches "abc" and "axc"
/a.c/ does not math "ac"
/a.c/ does not math "axxc"
/a\.c/ matches "a.c" \. removes the special meaning of dot.
/a\\c/ matches "a\c"
/a\/c/ matches "a/c"
/^abc/ matches first 3 characters in the line "abcd"
/^abc/ does not match anything in the line "dabc"
/abc$/ matches last 3 characters in the line "dabc"
/a[xyz]c/ matches "axc", "ayc", "azc"
's/[Tt]th[my]/YOU/g'
/a[a-z]c/ matches "abc" and any lower key letter from [a-z]
/a[a-zA-Z]c/ matches "abc" and "aBc"
's/[A-Z][a-z][a-z]/FROG/g'
's/[a-zA-Z] /* /'
's/the[^ ]/YOU/g'
/ab*c/ matches "abc" and "abbbbbc"
's/t[a-z]*/ZOO/g'
's/t[a-z][a-z][a-z]*/ZOO/g'
/(ab)*c/ matches "ababababababc"
s'/[A-Z][a-z]*/(&)/g'
's/\(they\) \(were\)/\2 \1/g'
's/\([Tt[hey\) \(were\)/\2 \1/g'
's/they \([a-z]*\)/\1ed/g'
Like this:
Like Loading...
Related
Recent Comments