Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I used below options in script to print on terminal as well as /var/log/messages

echo "System Load is OK : $Current_loadadv"
echo "System Load is OK : $Current_loadadv" | logger

but how can i do that in single line ?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted
tee >(logger) <<< "System Load is OK : $Current_loadadv"

>(logger) is bash syntax to create a file descriptor that is going to a FIFO, which is then fed to the standard input of logger (this is one form of what is known as "process substitution" in bash). It then passes back the path to that file descriptor as an argument to tee, and since tee writes to its non-option arguments, the FD is written to, and logger receives your string.

share|improve this answer
    
nice , thanks :-) –  Rahul Patil Dec 24 '12 at 10:55
    
@RahulPatil: I don't know if that's actually the case, but as a mnemonic to remember tee, think of the letter T, it looks like a circuit splitter :) –  Emanuel Berg Dec 25 '12 at 5:00
    
@EmanuelBerg Yes, that's the origin of the name tee. –  Chris Down Dec 25 '12 at 11:22
add comment

Another Option :

logger -s "Message"

man logger

-s Log the message to standard error, as well as the system log.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.