Reputation: 167
trying to tail and grep certain logs with $installingFil
and adding Command:
word before output in $DNLOG
file, but file is empty /private/tmp/DownLog.log
What will be the correct approach to echo "Command:" before every line.
I am not able to add/echo "Command:"
word before every line which is output in /private/tmp/DownLog.log
like:-
Command: bla bla
Command: downloding finish
Scrip -
#!/bin/bash
downFil=$(tail -f /var/log/system.log | grep 'Downloading files of')
dLog="/private/tmp/DownLog.log"
if [ -f /var/log/system.log ]; then
echo "Command:" "$downFil" >> "$dLog" # dLog is blank
else
echo "Command: Please wait.." >> $dLog # this works fine
fi
Upvotes: 0
Views: 612
Reputation: 6083
If I understand you correctly, you should try:
tail -f /var/log/system.log | grep 'Downloading files of' | sed 's/^/Command: /' >> /private/tmp/DownLog.log
Upvotes: 1