Adding time stamp to log file in bash script

Note you are outputting to Debug.log, while you should indicate the full path of that file: echo “Time: $(date)” >> /path/to/Debug.log. In general, whenever you want to add timestamp to a log file, you can use: echo “Time: $(date). Some error info.” >> /path/to/your/file.log date will expand to something like Fri Sep 9 12:18:02 CEST … Read more

awk: find minimum and maximum in column

Awk guesses the type. String “10” is less than string “4” because character “1” comes before “4”. Force a type conversion, using addition of zero: min=`awk ‘BEGIN{a=1000}{if ($1<0+a) a=$1} END{print a}’ mydata.dat` max=`awk ‘BEGIN{a= 0}{if ($1>0+a) a=$1} END{print a}’ mydata.dat`

Filter by Regex in JQ

If you tacked the following filter onto the one you already have, then you’d get the output shown below: map(select(.Address | test(“^[0-9]”))) Output: [ { “Address”: “1 Bridge Rd” } ] For robustness, you might like to consider adding ? after the test: map(select(.Address | test(“^[0-9]”)?)) Or, you could combine the two calls to map … Read more

Read a file using a bash script

There’s no reason to use cat here — it adds no functionality and spawns an unnecessary process. while IFS= read -r line; do echo “a line: $line” done < file To read the content of a file into a variable, use foo=$(<file). (Note that this trims trailing newlines.)