sed and awk for DBAs
OS - *ix Some useful sed, awk and bash commands for dbas. Some of them needs bit of improvements and might well have other better alternatives (e.g. one liners). 1. Provided with line by line list which needs to be put in to sql " IN " clause. [stefan@oc8233082860 ~]$ cat list.txt RMS_USER_ROLE_DEFINITION RMS_USER_ROLE RMS_USER_DETAILS [stefan@oc8233082860 ~]$ cat list.txt | awk -vORS=, '{ print $1 }' | sed 's/,$/\n/' > list2.txt [stefan@oc8233082860 ~]$ sed -r 's/,([^ ),]+)/,'\''\1'\''/g; s/,,/,'\'\'',/g' list2.txt RMS_USER_ROLE_DEFINITION,'RMS_USER_ROLE','RMS_USER_DETAILS' [stefan@oc8233082860 ~]$ 2. Getting datafile name removing the directory path. [stefan@pc_stefan ~]$ cat cmd_test.txt /dc2_db2/PACS/data/system.dbf /dc2_db2/PACS/data/undo.dbf /dc2_db2/PACS/data/sysaux.dbf /dc2_db2/PACS/data/pacs_cust_data01.dbf /dc2_db2/PACS/data/...