Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I need help with breaking down this script command by command on whatn it supposen to do!!

Status
Not open for further replies.

michealbantor

Technical User
May 25, 2018
6
US

michealbantor (TechnicalUser)
(OP)
26 May 18 00:46
[# command for gathering Listener Log

set v_listener_command "; echo ' Listener Log' | tr '\\n' ':'; echo '' | tr '\\n' ' ' ; lsnrctl status | grep Log | awk '{ print \$4 }' | sed 's/alert\\/log.xml/trace\\/listener.log/g' | tr '\\n' ' '; echo '-' | tr '\\n' ' ' ; du -sk `lsnrctl status | grep Log | awk '{ print \$4 }' | sed 's/alert\\/log.xml/trace\\/listener.log/g'` | awk '{ print \$1 }' | tr '\\n' ' ' ; echo '(KB)'"]
 
what it is supposed to do is relatively easy

it sets an environment variable "v_listener_command" to a value determined from a sequence of shell commands.

Breakdown:
a ; (semicolon) separates commands on a single line
s | (called a pipe) passes the result from the first command to the following 'piped' command

so;
Code:
 echo ' Listener Log' | tr '\\n' ':';
outputs a string and 'pipes' it to a tr command

Code:
 tr '\\n' ':'

tr is a 'translate' statement which replaces characters in a string.

your example replaces a newline character (\n) with a colon.

use
Code:
man 1 tr
in a shell window for more on tr.

Code:
lsnrctl status
Oracle database listener status request but not my department a I don't use Oracle. but the output is piped to grep for lines the word 'Log' then passes that to awk to get the 4th word/column of those lines.

Eg echo 'This is a test' | awk '{ print \$4 }' will return 'test'

[more to follow]

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
Meanwhile, back at the ranch;

Code:
 | sed 's/alert\\/log.xml/trace\\/listener.log/g'

sed .. is the UNIX/Linux Stream Editor, used for replacing, deleting, editing or inserting text in a text data stream or in files.

your example replaces all instances (the /g means global) of 'alert/log.xml' with 'trace/listener.log'

Code:
 man sed
for the manual pages.

Chris.

Indifference will be the downfall of mankind, but who cares?
Time flies like an arrow, however, fruit flies like a banana.

Never mind this jesus character, stars had to die for me to live.
 
You breakdown is much appreciated....thank you very much for your contribution.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top