Trimming Output to Your Terminal Width..

When tailing logs or reading through the output of any command and some lines are really too long, and they wrap around on the terminal – its really annoying.

Well I found this really cool tip at http://dec0de.me

Stick this function in your ~/.profile or equivalent:

fit () { 
    cut -c1-$COLUMNS
}

Now you have a nicer way to tail logs:

tail -F ~/home/some_app/logs/server.log | fit

It works a treat, thanks to Julien Letessier for sharing this one.

Advertisements
About

Assistant brewer. Ex DevOps Lead & backend code wrangler. Still likes to code. Into Go, APIs & Docker. Obviously an avid home brewer.

Tagged with: , ,
Posted in Linux, Mac OS X, Uncategorized

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: