The return value of two forms
return 0-255 0 indicates success, typically 1-255 ------- represents a failure for determining
Returns a string ------------ generally echo to return the result of performing a
return.sh
#!/bin/bash # this_pid=$$ function nginxck { ps -ef | grep nginx | grep -v grep | grep -v $this_pid | &> /dev/null if [ $? -eq 0 ];then return 0 else return 1 fi } nginxck && echo "nginx is running" || echo "nginx is stoped"
echo.sh
#!/bin/bash # function get_users { users=`cat /etc/passwd | cut -d ":" -f 1` echo $users } user_list=`get_users` index=1 for u in $user_list do echo "the $index user is : $u" index=`expr $index + 1` done