Monday, October 30, 2017

Sed - Example guide

sed is a very useful stream editor to perform search and replace. Below are some useful tip

1. Usage

sed 's/apple/orange/' file

The above will look for first occurrence of apple and replace with orange in the file and send the output to stdout

2. Make changes to the file

sed -i 's/apple/orange/' file

add -i option will make changes to the file itself

3. All occurrence changes

sed -i 's/apple/orange/g' file

adding g mean global replacement

4. Escape single quote

sed -i 's/'\''apple'\''/orange/' file

You can use '\'' to escape a single quote.

No comments:

Post a Comment

Oracle - ORACLE error 959 encountered when importing with imp

If the dump is exported with imp, you cannot use impdp and you may face issue such as IMP-00003: ORACLE error 959 encountered ORA-009...