Part2: Regular Expressions in AWK
Please read Part1: Introduction to AWK if you are new to using awk Let's consider awk.input as the input file for the examples we are going to look at in this post. cat awk.input SQL> select distinct 'alter tablespace ' || tablespace_name || ' end backup;' from v$backup, dba_data_files where v$backup.status='ACTIVE' and v$backup.file#=file_id; 'ALTERTABLESPACE'||TABLESPACE_NAME||'ENDBACKUP;' ----------------------------------------------------------- alter tablespace PSAPUNDO end backup; alter tablespace SYSAUX end backup; alter tablespace PSAPSIDDB end backup; alter tablespace PSAPSID640 end backup; alter tablespace PSAPSID end backup; alter tablespace PSAPSIDUSR end backup; alter tablespace SYSTEM end backup; SQL> spool off This file is the (altered) spool output of the endbackup script . To print the lines containing the word alter : awk '/alter/ { print }' < awk.input SQL> select distinct 'a...