I have a file with the below contents.
[oracle@hostname POST_DB_REFRESH_VALIDATIONS]$ cat .DB_Creds.txt
DEW:SYSTEM:ss2021:NPDOR
STW:SYSTEM:ss2021:NPDOR
When i run the below command in shell I am getting exact output as SYSTEM
[oracle@hostname POST_DB_REFRESH_VALIDATIONS]$ grep DEW .DB_Creds.txt | awk -F':' '{print $2}'
SYSTEM
whereas when i run the same in python3 command line using subprocess, i am getting the output as below.
Python 3.6.8 (default, Sep 26 2019, 11:57:09)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> output = subprocess.check_output("grep DEW .DB_Creds.txt | awk '{print $2}'", shell=True)
>>> print(output)
b'SYSTEM\n'
I just want it as SYSTEM, not with any other special characters.