Playing Sound in Putty during tail Option [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
My requirement is to play an alert (Play Sound) in putty if any Exception occurs in the Application , so for this purpose i have tried the below way
tail -f flex.log | grep "Exception" --color paplay alert.wav
But even though the word Exception occurs in flex Log File during tail , but it is not playing the sound .
Please let me know if there is any mistake in the above command .
I am using centOS 8 as OS and script is bash .

This will find all words with Exception and replace it with the bell character, your terminal should beep/flash/whatever you've set up to happen during a terminal bell.
tail -f flex.log | grep "Exception" | sed -e $'s/Exception/Exception\a/'
To see ALL lines of flex.log but bell only on "Exception":
tail -f flex.log | sed -e $'s/Exception/Exception\a/'

Related

What do terminal commands ls > wc and ls | wc show? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I know what the commands ls and wc do, but I can not find out what ls > wc and ls | wc will show. Can someone please help me flush out the meaning of this commands?
ls | wc The output from the ls command is piped into the wc command. So it will count the words which are in the output of ls. So you see simply the number of files read by ls.
ls > wc This creates a new file in your current working directory with the name wc with the output of your ls command. The program wc is not used here, simply a new file with the same name is created. You can simply look into this new file with your favorite editor or simply use cat for it.

Parsing a conf file in bash [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Here's my config file
#comment 1
--longoption1
#comment 2
--longoption2
#comment 3
-s
#comment 4
--longoption4
I want to write a bash script that will read this .conf file, skip comments and serialize the commandline options like so.
./binary --longoption1 --longoption2 -s --longoption4
Working off of this post on sed, you just need to pipe the output from sed to xargs:
sed -e 's/#.*$//' -e '/^$/d' inputFile | xargs ./binary
As Wiimm points out, xargs can be finicky with a lot of arguments and it might split it up across multiple calls to binary. It may be better off to use sed directly:
./binary $(sed -e 's/#.*$//' -e '/^$/d' inputFile)

linux/ unix command for checking specific logs [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
how can I extract a log based on specific time frame? Let's say issue started between 4pm to 5pm, how can I get that specific log between those times? I can use less or cat or grep but it would not give me the details of the error, sample command:
grep "2013-08-26 16:00:00" sample.log
what is the more precise Linux/ Unix command that can do the trick?
For viewing ERROR log messages between 16:00:00 and 17:00:00 use:
grep -nP '2013-08-15 16:.+ERROR' sample.log | less
If you have multiline messages in log you can use -A n and -B n params to add for each output string n lines after or before:
3 lines before and after each line:
grep -A 3 -B 3 -nP '2013-08-15 16:.+ERROR' sample.log | less
Shorthand for the same:
grep -3 -nP '2013-08-15 16:.+ERROR' sample.log | less
If you know that issue happened between 4 and 5 pm, you can use this:
grep "2013-08-26 16:" sample.log | less
If you need some lines around that issue, add option -N to grep (context of N lines), something like that:
grep -3 "2013-08-26 16:" sample.log | less
If you know that your event contained some specific word, you can filter it more using one more grep:
grep -3 "2013-08-26 16:" sample.log | grep somethingelse

Linux using grep command [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
After using grep command, i will give you a small example
grep test
test this is first line : 1
test this is second line : 2
test this is third line : 3
test this is fourth line : 4
How to filter the last line after grep command executed
finally i need the result 4
If I don't misunderstand you:
$grep test | tail -1
>test this is fourth line : 4
$grep test | tail -1 | awk '{print $7}'
>4
$7 is 'the seventh column' in awk.

Suppress Non-Matching Lines in Grep [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
Running service --status-all | grep "firestarter" in Ubuntu shows the entire output of service --status-all with the text "firestarter" highlighted in red. How do you get grep to only show the line that contains the matched text, and hide everything else?
Maybe service --status-all writes to stderr, not stdout? Then you can use
service --status-all 2>&1 | grep firestarter
You must have some weird env variables set. Try this:
service --status-all | `which grep` firestarter
Or:
service --status-all | /bin/grep firestarter
And show the output of env and alias if possible so we can see whats wrong with your grep command.
For me, I have:
[ 13:55 jon#host ~ ]$ echo $GREP_OPTIONS
--color=always
You probably have something set there, and/or in GREP_COLOR that is causing this.
if you don't want to use an alias, but the original command, you could try "\cmd". e.g.
service --status-all | \grep "firestarter"

Resources