[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Ruler
From: |
Stephane Chazelas |
Subject: |
Re: Ruler |
Date: |
Sat, 12 Dec 2015 13:33:59 +0000 |
User-agent: |
Mutt/1.5.21 (2010-09-15) |
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
- Ruler, valkrem, 2015/12/12
- Re: Ruler,
Stephane Chazelas <=
- Re: Ruler, Greg Wooledge, 2015/12/14