Processing content of a file or command output with “cut” (Linux)

Configurare noua (How To)

Situatie

Solutie

The cut command is used for cutting out the sections from each line of files or command output.
It can be used to cut parts of a line by byte position, character and field.

Syntax:
$ cut -d “delimiter” -f (field number) myfile.txt

Example: 
$ cut -d ":" -f 1 myfile.txt
$ cut -d ":" -f 2-8 myfile.txt

File content:

$ cat myfile.txt
207 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Patch 30095551 rollback: WITH ERRORS
208 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: logfile: /oracle/cfgtoollogs/sqlpatch/30095551/23036699/30095551_rollback_AGQ_2020Oct09_23_58_17.log (errors)
209 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Error at line 141: ORA-00060: deadlock detected while waiting for resource
210 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Error at line 994: Warning: Package Body created with compilation errors.
211 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Error at line 1000: 4378/12 PLS-00323: subprogram or cursor ‘PREP_SAVE_CS’ is declared in a
212 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Error at line 1003: 4396/13 PLS-00323: subprogram or cursor ‘ADDOBJTONUMTAB’ is declared in
213 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log:
214 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: Please refer to MOS Note 1609718.1 and/or the invocation log
215 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log: /oracle/cfgtoollogs/sqlpatch/sqlpatch_289374_2020_10_09_23_58_17/sqlpatch_invocation.log

Output of different options:

$ cut -d “:” -f 1 myfile.txt
207 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
208 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
209 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
210 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
211 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
212 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
213 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
214 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log
215 SXD202008_APPLY_AGQ_2020_10_09-23-58-10.log

$ cut -d “:” -f 2-8 myfile.txt
Patch 30095551 rollback: WITH ERRORS
logfile: /oracle/cfgtoollogs/sqlpatch/30095551/23036699/30095551_rollback_AGQ_2020Oct09_23_58_17.log (errors)
Error at line 141: ORA-00060: deadlock detected while waiting for resource
Error at line 994: Warning: Package Body created with compilation errors.
Error at line 1000: 4378/12 PLS-00323: subprogram or cursor ‘PREP_SAVE_CS’ is declared in a
Error at line 1003: 4396/13 PLS-00323: subprogram or cursor ‘ADDOBJTONUMTAB’ is declared in

Please refer to MOS Note 1609718.1 and/or the invocation log
/oracle/cfgtoollogs/sqlpatch/sqlpatch_289374_2020_10_09_23_58_17/sqlpatch_invocation.log

Tip solutie

Permanent

Voteaza

(11 din 23 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?