2015-12-11 20:41:26 -0700, valkrem:
> Hi all,
>
> I am looking for a screen ruler (script) that display the column position of
> a variables for a given file.
>
>
> Example
> Assume I have a file named "test" and has three variables
>
> Id Date length
>
> 123 20150518 2750
> 125 20140324 3500
>
> When I invoke the command -ruler ( or the script name) I will see the
> following
>
> bash$ ruler test
> 1 2 3
> 12345678901234567890
> -----------------------------------
> 123 20150518 2750
> 125 20140324 3500
[...]
Maybe something like:
#! /bin/bash -
shopt -s checkwinsize
(:) # seems to trigger bash to set $COLUMNS
cat "$@" |
awk -v c="$COLUMNS" -v l="$LINES" 'BEGIN {
for (i = 1; i <= c; i++) {
a = a (i % 10 ? " " : (i/10)%10)
b = b (i % 10)
}
}
NR % (l-5) == 1 {print a "\n" b}
{print}' | less -S
--
Stephane