Tail/head by screenfuls in zsh
It's often a lot easier to think in terms of "I want half a screen" than "I want 30 lines" so I wrote some aliases to wrap tail & head into this case.
Code
# Tail/head by screenfuls, via zsh function.
# Yay zshell~
stail () {
# Use zsh's arithmetic substitution to do the math
# then cast to an integer to round it off
integer l=$(($LINES * $1))
tail -n$l $2
}
shead () {
# Use zsh's arithmetic substitution to do the math
# then cast to an integer to round it off
integer l=$(($LINES * $1))
head -n$l $2
}
Usage
# half a screenful, tail
$ stail 0.5 file
# two screenfuls, head
$ shead 2 file
Idea from https://twitter.com/seb_m/status/365185187996368896
Written by Peter Lejeck
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Nuckchorris
Authors
nuck
1.296K
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#