Find the answer to your Linux question:
Results 1 to 3 of 3
Can someone advise me on how to make the output of an awk statement a different colour? My statement is: Code: awk -v KEY=/$input/ 'BEGIN { FS = "," } ...
  1. #1
    Just Joined!
    Join Date
    Oct 2008
    Location
    Edinburgh, Scotland
    Posts
    18

    Red face Colour in awk command

    Can someone advise me on how to make the output of an awk statement a different colour?

    My statement is:

    Code:
    awk -v KEY=/$input/ 'BEGIN { FS = "," } KEY { print "Name: " $2 }' data1.csv
    The statement retrieves data from a csv file, what I want is the value $2 a different colour from Name:

    Any help would be appreciated

  2. #2
    Just Joined!
    Join Date
    Oct 2008
    Posts
    10
    In bash:

    esc="\033" # if this doesn't work, enter an ESC directly
    blue="${esc}[34m"
    reset="${esc}[0m"

    cat <<EOF
    ${blue}this is a frase in blue${reset}
    EOF

    this will work only if your terminal or window supports color ansii sequences

  3. #3
    Just Joined!
    Join Date
    Oct 2008
    Location
    Edinburgh, Scotland
    Posts
    18
    Thanks very much Creepy,

    where exactly do I enter your code i.e. before, after or within my awk command?

    Thanks again

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...