Printing verbose progress from sed and awk

This is based on potong’s answer. The following code replaces ‘ll’ with ‘zz’, creates a backup file, displays the new text, and writes the change(s) into the file. $ echo hello > test $ sed -e ‘s/ll/zz/;w /dev/stdout’ -i .backup test hezzo $ cat test hezzo $ cat test.backup hello

How can I check the version of sed in OS X?

This probably isn’t the answer you’re looking for, but you can’t. Mac OS X sed has no option to show the version number. There is not even a version number in the binary: $ strings $(which sed) $FreeBSD: src/usr.bin/sed/compile.c,v 1.28 2005/08/04 10:05:11 dds Exp $ $FreeBSD: src/usr.bin/sed/main.c,v 1.36 2005/05/10 13:40:50 glebius Exp $ $FreeBSD: src/usr.bin/sed/misc.c,v … Read more

Using ? with sed

The equivalent to x? is \(x\|\). However, many versions of sed support an option to enable “extended regular expressions” which includes ?. In GNU sed the flag is -r. Note that this also changes unescaped parens to do grouping. eg: echo ‘file_1.gz’|sed -n -r ‘s/.*_(.*)(\.gz)?/\1/p’ Actually, there’s another bug in your regex which is that … Read more

Escape single quote

Your question is a little confusing since there’s no me in the original string to replace. However, I think I have it. Let me paraphrase: I have a sed command which can successfully replace a single quote ‘ with the word me. I want a similar one which can replace it with the character sequence … Read more

sed: insert a string after every N lines

This thread is another example of how to over complicate things. This should do it: sed ‘0~30 s/$/string/g’ < inputfile > outputfile Every 30 lines “string” is inserted at the end of the line. If you want a new line with the word “string” just use “\n string”.

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