Below is the tail statement:

tail -4 FDECMP1_$$.log

I need to print the last 4 lines of file FDECMP1_$$.log in Red.


This command will do the job:

printf "%s" $(printf '\033[0;31m');tail -4 FDECMP1_$$.log
  • Maybe you need to reset the colour after the tail command, though. – Ned64 Feb 14 '18 at 8:32

As @galoget showed, you can use the ANSI escape sequences to change the coloring of shell texts.

This answer has more information on this and a nice xterm-256-color-chart to conveniently find the correct color for your purposes.

  • Why answer the question again when it is already answered? In these cases, please add a comment to the existing answer, instead. – Ned64 Feb 14 '18 at 8:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.