2

I am kinda new to Linux.

My base issue: I need to show the output of curl cheat.sh/python like a man or less page, so that I can easily scroll up and down.

What have I tried: curl cheat.sh/python | less

outout: some weird text like this-

ESC[38;5;246m# Python is a high-level programming languageESC[39m ESC[38;5;246m# and python is a Python interpreter.ESC[39m

ESC[38;5;246m# Basic example of server with pythonESC[39m ESC[38;5;246m# Will start a Web Server in the current directory on port 8 000ESC[39m ESC[38;5;246m# go to http://127.0.0.1:8000ESC[39m ESC[38;5;246m#ESC[39m ESC[38;5;246m# Python v2.7ESC[39m ESC[38;5;252mpythonESC[39mESC[38;5;252m ESC[39mESC[38;5;252m-mESC[39mESC[ 38;5;252m ESC[39mESC[38;5;252mSimpleHTTPServerESC[39m ESC[38;5;246m# Python 3ESC[39m ESC[38;5;252mpythonESC[39mESC[38;5;252m ESC[39mESC[38;5;252m-mESC[39mESC[ 38;5;252m ESC[39mESC[38;5;252mhttp.serverESC[39mESC[38;5;252m ESC[39mESC[ 38;5;67m8000ESC[39m ...

After having a look at this, I tried: curl -vs cheat.sh 2>&1 | less

but output was kinda same:

Accept: / * Mark bundle as not supporting multiuse HTTP/1.1 200 OK Server: nginx/1.13.12 Date: Wed, 25 Mar 2020 17:50:04 GMT Content-Type:

text/plain; charset=utf-8 Content-Length: 25502 Connection: keep-alive

Strict-Transport-Security: max-age=63072000; includeSubdomains

X-Frame-Options: DENY X-Content-Type-Options: nosniff { [2429 bytes data] ESC[38;2;0;204;0m_ESC[0mESC[38;2;0;204;0m_ESC[0mESC[38;2;0;204;0m ESC[0mESC[38;2;0;204;0m ESC[0mESC[38;2;0; 204;0m ESC[0m
| | __ | | _| |__ ESC[38;2;0;204;0m\ESC[0mESC[38;2;0;204;0m ESC[0mESC[38;2;0;204;0m\ESC[0mESC[38;2;0;204;0m ESC[0mESC[38;2;0; 204;0m ESC[0m ESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85mTESC[0mESC[48;2;85;85;85mhESC[0mESC[48 ;2;85;85;85meESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85moESC[0mESC[48;2;85;85;85mnESC[0mESC[48;2;85;85;85mlESC[0mESC[48;2;85;85;85myESC[0m ESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85mcESC[0mESC[48;2;85;85;85mhESC[0mESC[48;2;85;85;85meESC[0mESC[48;2;85;85;85maESC[0mESC[48;2;85;85;85mt ESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85msESC[0mESC[48;2;85;85;85mhESC[0mESC[48;2;85;85;85meESC[0mESC[48;2;85;85;85meESC[0mESC[48;2;85;85 ;85mtESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85myESC[0mESC[48;2;85;85;85moESC[0mESC[48;2;85;85;85muESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2; 85;85;85mnESC[0mESC[48;2;85;85;85meESC[0mESC[48;2;85;85;85meESC[0mESC[48;2;85;85;85mdESC[0mESC[48;2;85;85;85m ESC[0mESC[48;2;85;85;85m ESC[0mESC[ 48;2;85;85;85m ESC[0m ...

Finally if I change the above code like (this is probably the wrong approach) : curl -vs cheat.sh 1>&2 | less

Then I will get the needed output of curl, but upon pressing a button the terminal shows like:

~

~

~

~

~

~

~

~

~

~

~ (END) and I can basically press q to quit out of less from there.

2
3

Use the -R option of less, so that it interprets these codes as colour. It is rendering the codes in a human readable way. However can pass them to the terminal to be interpreted as colour. -r passes everything to terminal, -R only does this for colour.

curl cheat.sh/python | less -R

1
  • Yes. Thankyou. I didn't know the issue was with interpreting colors. Mar 26 '20 at 2:43

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