sed insert line command OSX

You should put a newline directly after the \: sed ‘3i\ text to insert’ file This is actually the behaviour defined by the POSIX specification. The fact that GNU sed allows you to specify the text to be inserted on the same line is an extension. If for some reason you need to use double … Read more

Using sed to remove a block of text

$ cat text abc <!– BOF CLEAN –> … a bunch of stuff <!– EOF CLEAN –> def $ sed ‘/<!– BOF CLEAN –>/,/<!– EOF CLEAN –>/d’ text abc def I cannot explain it any better than Sed One-Liners Explained, Part III: Selective Deletion of Certain Lines and Special Applications.

PCRE Regex to SED

Want PCRE (Perl Compatible Regular Expressions)? Why don’t you use perl instead? perl -pe ‘s/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g’ \ <<< “My email is abc@example.com” Output: My email is [emailaddr] Write output to a file with tee: perl -pe ‘s/[a-zA-Z0-9]+[@][a-zA-Z0-9]+[\.][A-Za-z]{2,4}/[emailaddr]/g’ \ <<< “My email is abc@example.com” | tee /path/to/file.txt > /dev/null

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)