• 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!

  • 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?

  • @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.

    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

  • @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.

  • 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.


    Thanks very much to @Modisc and @karasu for helping me

terminal44 color13 specific9 export3 Posts 6Views 1421
Log in to reply
Bloom Email Optin Plugin

Looks like your connection to Antergos Community Forum was lost, please wait while we try to reconnect.