Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,37 @@
cat <<EOF_OUTER > just-nocenter.sh
#!/bin/sh
td() {
cat <<'EOF'
Given$a$text$file$of$many$lines,$where$fields$within$a$line$
are$delineated$by$a$single$'dollar'$character,$write$a$program
that$aligns$each$column$of$fields$by$ensuring$that$words$in$each$
column$are$separated$by$at$least$one$space.
Further,$allow$for$each$word$in$a$column$to$be$either$left$
justified,$right$justified,$or$center$justified$within$its$column.
EOF
}
rows=$( td | wc -l )
# get the number of fields
fields=$(td | rs -c'$' -g1 -h | awk '{print $2}')
# get the max of the value widths
cwidth=$(td | rs -c'$' -g1 -w1 2>/dev/null | awk 'BEGIN{w=0}{if(length>w){w=length}}END{print w}')
# compute the minimum line width for the columns
lwidth=$(( (1 + cwidth) * fields ))
# left adjusted columns
td | rs -c'$' -g1 -zn -w$lwidth
echo ""
# right adjusted columns
td | rs -c'$' -g1 -znj -w$lwidth
echo ""
exit
EOF_OUTER

View file

@ -0,0 +1,14 @@
$ ./just-nocenter.sh
Given a text file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a program
that aligns each column of fields by ensuring that words in each
column are separated by at least one space.
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its column.
Given a text file of many lines, where fields within a line
are delineated by a single 'dollar' character, write a program
that aligns each column of fields by ensuring that words in each
column are separated by at least one space.
Further, allow for each word in a column to be either left
justified, right justified, or center justified within its column.

View file

@ -0,0 +1 @@
tr '$' ' ' | column -t