Search Results

Search: Posts Made By: monty77
7,387
Posted By agama
Bugger! I need to call it a night and go to bed....
Bugger! I need to call it a night and go to bed.

Test should be AND rather than OR.


if [[ $last_value != "x" && $last_value != $new_value ]]
7,387
Posted By agama
Right about bash, however Ksh does the right...
Right about bash, however Ksh does the right thing and this will work in ksh.


$ cat t19
#!/usr/bin/env ksh
x=
echo hello | read x
echo $x

$ t19
hello
7,387
Posted By agama
Oops, typo. The [[ needs to have a trailing...
Oops, typo.

The [[ needs to have a trailing space.


if [[ $last_value != "x" || $last_value != $new_value ]]


Sorry bout that.
7,387
Posted By agama
Cool -- glad you found something that works for...
Cool -- glad you found something that works for you. Yes, change the if a bit to skip if last_value is 'x' or whatever you initialised it to. Something like:


if [[ $last_value != "x" && ...
7,387
Posted By agama
Good -- a single shot command is much easier to...
Good -- a single shot command is much easier to deal with.

I miss read the grep -- realise now that you are ditching the 'name' line. If the value that you are interested in is always the last...
7,387
Posted By agama
I assumed that your command ran a single time,...
I assumed that your command ran a single time, though looking back at your example maybe it executes continuously.

Small changes:

last_value=x
log_file=/tmp/log.file

your-command-string |...
7,387
Posted By agama
Try something like this: last_value=x ...
Try something like this:



last_value=x
log_file=/tmp/log.file
while true
do
your-command-string | read new_value
if [[ $last_value != $new_value ]]
then
echo "$(date)...
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 07:17 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy