Je me mets ça de côté pour gagner du temps la prochaine fois
logfile=/tmp/logfile.log
errorfile=/tmp/error.log
function log() {
echo -e "\e[34m\e[1m[$(date +%Y-%m-%d) $(date +%H:%M:%S)] $1\e[0m" | tee -a /tmp/logfile.log
}
function logerror() {
echo -e "\e[91m\e[1m[$(date +%Y-%m-%d) $(date +%H:%M:%S)] $1\e[0m" | tee -a /tmp/logfile.log
}
log "prout"
logerror "pwet"
-
https://links.infomee.fr/?tQ0ssAfunction sayhello() {
echo hello
}
OR
sayhello() {
echo hello
}
Et en one-line :
sayhello() { echo hello; }
-
https://links.infomee.fr/?zlvmKwJe prefere la deuxieme solution :
function myfunc()
{
local myresult='some value'
echo "$myresult"
}
result=$(myfunc) # or result=myfunc
echo $result
-
http://www.linuxjournal.com/content/return-values-bash-functions