Monday 30 November 2020

Using grep to display lines around the match also

 Example:

>grep -i  -C 2 "Module: my_program" report20201129*


In this case, we want to display the line above the ones that matches the pattern, since it contains important info.


Wednesday 23 September 2020

Having fun with "for" loops in Linux

  >for i in {1..61}

> do

> for j in {01..12}

> do

> echo "create synonym us$i$j for usage_dummy;" >> 1.sql

> echo "create synonym au$i$j for accumulates_usage_dummy;" >> 1.sql

> done

> done


Friday 4 September 2020

How to find special characters in the DB

  Match nth character

SQL> select case when regexp_like('ter*minator' ,'^...[^[:alnum:]]') then 'Match Found' else 'No Match Found' end as output from dual;

Output: Match Found


In the above example we tried to search for a special character at the 4th position of the input string “ter*minator”

Let’s now try to understand the pattern '^...[^[:alnum:]]'

^ marks the start of the string
. a dot signifies any character (… 3 dots specify any three characters)
[^[:alnum:]] Non alpha-numeric characters (^ inside brackets specifies negation)

Note: The $ is missing in the pattern. It’s because we are not concerned beyond the 4th character and hence we need not mark the end of the string. (...[^[:alnum:]]$ would mean any three characters followed by a special character and no characters beyond the special character)



https://www.orafaq.com/node/2404

Monday 31 August 2020

How to zip/unzip files on the fly, when we have space constraints

 To unpack on the fly:

gunzip < FILE.tar.gz | tar xvf -


To pack on the fly:
tar cvf - FILE-LIST | gzip -c > FILE.tar.gz


Another method, without creating a tar on the local server at all:


server1> tar cvf - 19.3.0 | ssh oracle@server2 "tar xvf - -C /u01/app/oracle/product"