Quantcast
Viewing all articles
Browse latest Browse all 5067

Advanced users • Colouring writes to 'dmesg'

echo "Hello World" | sudo tee /dev/kmsg

I have been using similar for a while and it works fine, shown without its coloured glory here ...

Code:

pi@Pi4B:~/ $ echo "Hello World" | sudo tee /dev/kmsgpi@Pi4B:~/ $ dmesg | tail -n 4[77628.573546] usb 1-1.4: Manufacturer: MicroPython[77628.573549] usb 1-1.4: SerialNumber: e660583883278628[77628.581650] cdc_acm 1-1.4:1.0: ttyACM0: USB ACM device[111806.239588] Hello Worldpi@Pi4B:~ $
The question is how to force a colour for the message rather than the one it gets by default, which seems to be bright white ?

I can use echo -en "\033[0;36m Cyan\n" | sudo tee /dev/kmsg and that colours the text echoed to the console but it puts the raw characters in dmesg; "[113032.039568] \x1b[0;36m Cyan".

Googling for a couple of days hasn't helped so does anyone know the magical incantation ?

Statistics: Posted by hippy — Fri Nov 29, 2024 2:32 pm



Viewing all articles
Browse latest Browse all 5067

Trending Articles