Created
February 15, 2023 14:52
-
-
Save mbreese/dbf90beb0b3aa29d12ed9f0723a4de76 to your computer and use it in GitHub Desktop.
Quick script to convert stdin to a line size that fits the screen. For example, `ps -e` will return only lines that fit on the current screen. If you want to grep that output, you get all of the data and it wraps the screen. If you pipe `ps -e | grep foo | fit`, then you get the trimmed output again.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
COLS="$(tput cols)" | |
while read LINE; do | |
echo $LINE | head -c $COLS | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment