Showing 1 changed files with 28 additions and 2 deletions
+28 -2
README.md
... ...
@@ -68,8 +68,9 @@ LOGFILE="<path>/to.log"
68 68
 function log() {
69 69
   if [ 1 -eq $LOG_ENABLED ]
70 70
   then
71
-    DATE=$(date)
72
-    echo "$DATE $(hostname) $(basename $0): $@" >> $LOGFILE
71
+    DATELOG=$(date)
72
+    echo -e "$@"
73
+    echo -e "$DATELOG $(hostname) $(basename $0): $@" >> $LOGFILE
73 74
   fi
74 75
 }
75 76
 
... ...
@@ -126,3 +127,28 @@ urldecode() {
126 127
 ```bash
127 128
 lsof -i4 -n
128 129
 ```
130
+
131
+# Colors in scripts
132
+use with **echo -e**
133
+```bash
134
+GREEN="\\033[1;32m"
135
+RED="\\033[1;31m"
136
+MAGENTA="\\033[1;35m"
137
+BLUE="\\033[1;34m"
138
+WHITE="\\033[0;02m"
139
+LIGHTGREY="\\033[1;08m"
140
+YELLOW="\\033[1;33m"
141
+CYAN="\\033[1;36m"
142
+NORMAL="\\033[0;39m"
143
+```
144
+
145
+# Replace a key=value in a file
146
+```
147
+sed -i "s/key=.*/gain=NEW/" infile
148
+```
149
+In a section
150
+```
151
+sed -i '/^\[section\]/{$!{N;s/gain=.*/key=NewMULTILINE/;ty;P;P;:y}}' infile
152
+```
153
+
154
+