I would like to ask you how can I hide echo from my function but still use its echo as a variable for next processing.
My code is:
function str_str {
local str
str="${1#*${2}}"
str="${str%%$3*}"
echo -n "$str"
}
mystr=$(cat /etc/logrotate.conf)
str_str "$mystr" "access.log" "}"
OKACCESS=$(str_str "$mystr" "access.log" "}" | grep -e "daily" -e "size" -e "rotate" -e "create" -e "weekly" -c)
echo $OKACCESS
When I remove the:
echo -n "$str"
I can not use it as a variable for OKACCESS, which returns 0, should return 4 (works with echo not hidden or passed to dev>null).
How do I hide output of the function without limiting the definition of OKACCESS variable?
Thank you for help.
E:
What I am trying to do:
When I execute my current script, its output is:
[root@env test]# ./tester.sh
{
missingok
daily
rotate 10
create 0664 jboss jboss
postrotate
/usr/bin/kill -s SIGHUP `cat /var/run/syslogd.pid`
endscript
dateext
4
When I remove the "echo -n "$str"" part, I get this:
0
and I need this:
4