• How to export a terminal output in a specific color.


    Hi i need some help from you guys…
    The history:
    I installed “weather”, a CLI tool to check the weather. I need to take the actual temperature exported to a file, but the problem is that it uses colors, changing according to the temperature. So here’s the command i use:
    curl wttr.in/Porto_Alegre | sed -n -e 4p It takes the temperature and filter only the 4th line.
    curl wttr.in/Porto_Alegre | sed -n -e 4p > a.txt The generated file is a mess with a lot of numbers…
    So how can i use the command exporting the color to black/write or something like that?
    Thanks for your help!

    Antergos (default OS) - WIN10 (abandoned)
    I3wm - Mate desktop
    AMD - A4 7300 Radeon graphics
    16 GB ram
    HD 1 TB
    Linux newbie since 06/2016

  • I am none too sure but I wonder that the command tput would be of some help.
    So man tput
    I"ve never used that command but it’s to be used to set and modify the prompt settings.
    Is that something that you were looking for?

    EDIT: There is something that I found on the net.
    Am not too sure if it would be of any help.
    I’ve never used the tput command.
    Only have heard of it.
    But a link on how to explain it ( with examples ) is here: link text

    Can you show an example?

    Download " antergos-wallpapers-extra " and enjoy community sponsored wallpapers.

    Use the "Linux Beginner Search Engine"

    https://cse.google.com/cse/home?cx=017607476515012185699:b_owgx6xyi0

  • @Modisc well i guess not, i read this post before, but i can’t find a way to use cat and tput working together. Or nothing is displayed or the cat output keeps the same i mentioned before. It change the terminal color but cat make it back to normal.

    example:
    I exported the information i need to "5.txt"
    no output>
    $ cat 5.txt | tput setaf 1
    $

    Or the output comes back to standard color:
    $ tput setaf 1 | cat 5.txt
    .--. 23 – 25 °C

    Or standard color with errors
    $ cat 5.txt $(tput setaf 1)
    .--. 23 – 25 °C
    cat: ''$'\033''[31m': Arquivo ou diretório não encontrado
    $ cat $(tput setaf 1) 5.txt
    cat: ''$'\033''[31m': Arquivo ou diretório não encontrado
    .--. 23 – 25 °C

    Antergos (default OS) - WIN10 (abandoned)
    I3wm - Mate desktop
    AMD - A4 7300 Radeon graphics
    16 GB ram
    HD 1 TB
    Linux newbie since 06/2016

  • @fernandomaroto
    As I’m none too familiar with trying out in doing what you need, give me a day or so to see what better answers there are available for you.
    I understand your issue. Basically cat is returning the changes back to default. Which is not what you want.
    You want the changes to remain so that your temperature is on black or white.
    Something that is more readable because colors don’t always make the text readable.
    I’ll post back and see what answers there are. I’m sure that there are.

    Download " antergos-wallpapers-extra " and enjoy community sponsored wallpapers.

    Use the "Linux Beginner Search Engine"

    https://cse.google.com/cse/home?cx=017607476515012185699:b_owgx6xyi0

  • lol, i had seen this site but the commands seemed too complicated. I just tried again, the first one didn’t work but the second was just copy and paste.

    cat 5.txt | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" > 6.txt
    that way i can export the file without text format, now i inject into conky-manager config, i changed it to display temperature without receiving information from weather sites.

    http://storage1.static.itmages.com/i/16/1231/h_1483212720_9202898_74b621cc8e.png

    Thanks very much to @Modisc and @karasu for helping me
    Uhuhu
    Cheers!

    Antergos (default OS) - WIN10 (abandoned)
    I3wm - Mate desktop
    AMD - A4 7300 Radeon graphics
    16 GB ram
    HD 1 TB
    Linux newbie since 06/2016

specific3 export2 terminal26 color4 Posts 6Views 332
Log in to reply