Monday 31 January 2011

Advanced SED Tutorial. Multiline Sed commands

1. If a line starts with / remove / sign.
$sed 's/^\/ *//g'

2. If a line starts with TABLESPACE remove it.
$sed 's/^TABLESPACE.*//g'

3. If line starts with ) proceeds with none or more spaces replace it with ) and next line.
$sed 's/^) */)\n\//g'

4. Replace ; with ; and next line.
$sed -i 's/;/;\n/g'

5. This command replaces ; \t\n\r or spaces and the / in a file to just \n /.
$sed ':a;N;$!ba;s/[^end];[\n\t\r ]*\//\n\//g'

First of all the filw is all read in come variable N and then we perform operation on it. Its a Multiline function.

6. Line starting with END or end or any of Upper or Lower combination of end, will be ended with a ;
$sed 's/^[eE][nN][dD].*/&;/g'

No comments:

Post a Comment

Azure OpenAI Architecture Patterns & Deployment Patterns

Sharing some useful links that will help customers architect Azure OpenAI solution using the best practices: (1) Azure OpenAI Landing Zone r...