Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
s/echo/printf/ -- and some extra juju to go with
- Loading branch information
1 parent
3dcc61d
commit a4726de
Showing
20 changed files
with
91 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,36 @@ | ||
#!/bin/bash | ||
|
||
if [[ $# -ne 2 ]]; then | ||
echo "Usage: $0 <columns> <input file>" >&2 | ||
exit 1 | ||
fi | ||
(( $# != 2 )) && { printf "Usage: %s <columns> <input file>\n" "${0##*/}"; exit 1; } >&2 | ||
|
||
# Redirect STDOUT to an html file | ||
exec >> output.html | ||
|
||
# Start table | ||
echo "<table>" | ||
printf "<table>\n" | ||
|
||
count=0 # Initialize a counter for columns | ||
while read line; do | ||
if [[ $count -eq 0 ]]; then | ||
# We're at the start of a new row, open it. | ||
printf "\t<tr>\n" | ||
fi | ||
|
||
if [[ $count -lt $1 ]]; then | ||
# Print next line from data file | ||
printf "\t\t<td>%s</td>\n" "$line" | ||
fi | ||
|
||
(( count++ )) | ||
|
||
if [[ $count -eq $1 ]]; then | ||
# We're at the end of a row, close it. | ||
printf "\t</tr>\n" | ||
count=0 | ||
fi | ||
done < $2 | ||
if [[ $count -eq 0 ]]; then | ||
# We're at the start of a new row, open it. | ||
printf "\t<tr>\n" | ||
fi | ||
|
||
if [[ $count -lt $1 ]]; then | ||
# Print next line from data file | ||
printf "\t\t<td>%s</td>\n" "$line" | ||
fi | ||
|
||
(( count++ )) | ||
|
||
if [[ $count -ne 0 ]]; then | ||
# Kludge for when columns doesn't divide equally into data size | ||
if [[ $count -eq $1 ]]; then | ||
# We're at the end of a row, close it. | ||
printf "\t</tr>\n" | ||
fi | ||
count=0 | ||
fi | ||
done < $2 | ||
|
||
# Kludge for when columns doesn't divide equally into data size | ||
(( count )) && printf "\t</tr>\n" | ||
|
||
# End table | ||
echo "</table>" | ||
printf "</table>\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.