table

Помоћни програм из командне линије за форматирање и приказ CSV-а
git clone https://git.sr.ht/~strahinja/table
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 6f6a902010de6749bb20c317915b4d1b212af6ba
родитељ 4aa35f4868979e7ca07a03908c8caa61d848391b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Sat,  6 Jul 2024 14:23:21 +0200

Tidy up tests

Diffstat:
Mtest/ls-2col.sh | 4++--
Mtest/ls-adv.sh | 6++++--
Mtest/ls-multicolumn.sh | 26+++++++++++++++++++++++++-
измењених датотека: 3, додавања: 31(+), брисања: 5(-)

diff --git a/test/ls-2col.sh b/test/ls-2col.sh @@ -1,3 +1,3 @@ #!/bin/sh -LC_ALL=C ls -l | tail -n +2 | sed -e's/ \+/ /g' | cut -d' ' -f1,9 \ - | table -d " " -c 30 -n +LC_ALL=C ls -l | tail -n +2 | sed -E 's/[[:space:]]+/ /g' | + cut -d' ' -f1,9 | table -d ' ' -c 30 -n diff --git a/test/ls-adv.sh b/test/ls-adv.sh @@ -1,3 +1,5 @@ #!/bin/sh -LC_ALL=C ls -l | tail -n 15 | sed -e's/ \+/ /g' -e's/\t/ /g' \ - | table -d " " -c 120 -s ss -n +t=$(printf '\t') +LC_ALL=C ls -l | tail -n 15 | + sed -Ee 's/[[:space:]]+/ /g' -e 's/'"$t"'/ /g' | + table -d ' ' -c 120 -s ss -n diff --git a/test/ls-multicolumn.sh b/test/ls-multicolumn.sh @@ -1,2 +1,26 @@ #!/bin/sh -LC_ALL=C ls -m /bin | sed -e's/,$//g' -e's/, /,/g' | table -c 160 -n + +# Longer version in awk +#{ LC_ALL=C ls -m /bin | sed -E -e 's/, /,/g' | tr -d '\n' +# echo; } | +# awk -v RS=, ' +#{ +# if (NR > 1) +# { +# if (!((NR-1) % 8)) +# { +# printf "\n" +# } +# else +# { +# printf "," +# } +# } +# printf +#}' | +#table -c 160 -n -d, + +# sed version +{ ls -m /bin | tr -d '\n'; echo; } | + sed -E 's/(([^, ]*, *){0,7})([^, ]*)(, *)?/\1\3\ +/g;s/, /,/g;s/\n$//' | table -c 160 -n -d,