Monday, November 2, 2020

sed command in unix

$ vi sample.txt
$ cat sample.txt
one two three
this is example for sed substitution
$ cat sample.txt|sed 's/t/T/'
one Two three
This is example for sed substitution
$ cat sample.txt|sed 's/t/T/g'
one Two Three
This is example for sed subsTiTuTion
$ sed 's/t/T/g' sample.txt
one Two Three
This is example for sed subsTiTuTion
$ cat sample.txt
one two three
this is example for sed substitution
$ sed -i 's/t/T/g' sample.txt
$ cat sample.txt
one Two Three
This is example for sed subsTiTuTion
$
**************************************************************************
[oracle]$ cat sample.txt
one two three
10 aug 1991
5 may 2020
sed command is used to replace string or characters
[oracle]$ sed 's/[0-9]/*/g' sample.txt
one two three
** aug ****
* may ****
sed command is used to replace string or characters
[oracle]$ sed 's/[0-9][0-9]/*/g' sample.txt
one two three
* aug **
5 may **
sed command is used to replace string or characters
[oracle]$ sed 's/[0-9]/(&)/g' sample.txt
one two three
(1)(0) aug (1)(9)(9)(1)
(5) may (2)(0)(2)(0)
sed command is used to replace string or characters
[oracle]$ sed 's/[a-z]/(&)/g' sample.txt
(o)(n)(e) (t)(w)(o) (t)(h)(r)(e)(e)
10 (a)(u)(g) 1991
5 (m)(a)(y) 2020
(s)(e)(d) (c)(o)(m)(m)(a)(n)(d) (i)(s) (u)(s)(e)(d) (t)(o) (r)(e)(p)(l)(a)(c)(e) (s)(t)(r)(i)(n)(g) (o)(r) (c)(h)(a)(r)(a)(c)(t)(e)(r)(s)
[oracle]$ sed -i  's/t/T/g' sample.txt
[oracle]$ cat sample.txt
one Two Three
10 aug 1991
5 may 2020
sed command is used To replace sTring or characTers
[oracle]$ sed 's/[a-z]/*/g' sample.txt
*** T** T****
10 *** 1991
5 *** 2020
*** ******* ** **** T* ******* *T**** ** ******T***
[oracle]$ sed 's/[A-Z]/*/g' sample.txt
one *wo *hree
10 aug 1991
5 may 2020
sed command is used *o replace s*ring or charac*ers
[oracle]$ sed 's/[A-Za-z]/*/g' sample.txt
*** *** *****
10 *** 1991
5 *** 2020
*** ******* ** **** ** ******* ****** ** **********
[oracle]$ sed 's/[a-Z]/*/g' sample.txt
*** *** *****
10 *** 1991
5 *** 2020
*** ******* ** **** ** ******* ****** ** **********
[oracle]$ sed 's/[0-Z]/*/g' sample.txt
*** *** *****
** *** ****
* *** ****
*** ******* ** **** ** ******* ****** ** **********
You have mail in /var/spool/mail/ougbs
[oracle]$ sed 's/[0-5]/*/g' sample.txt
one Two Three
** aug *99*
* may ****
sed command is used To replace sTring or characTers
[oracle]$ sed 's/[d-m]/*/g' sample.txt
on* Two T*r**
10 au* 1991
5 *ay 2020
s** co**an* *s us** To r*p*ac* sTr*n* or c*aracT*rs
[oracle]$
*********************************************************************

No comments:

Post a Comment

Delete Row Button to all records of Interactive Report in Oracle Apex

 1. add 'Delete' Del column to Report Query 2. Set the Following Properties for the DEL Column Type: Link Heading: Delete Targ...