From 59d7c59c017b41e7894ffbe026a4404d02afcfa4 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Wed, 3 Jun 2015 11:13:37 +0200 Subject: Use a jot wrapper for Linux --- makecolumns.sh | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/makecolumns.sh b/makecolumns.sh index 8df1c25..bdb04b3 100755 --- a/makecolumns.sh +++ b/makecolumns.sh @@ -193,7 +193,7 @@ handle_format_version_3() { # Now loop over all files and dump them printf "Splitting decompressed nname chunks into their columns ... " - jot -w %0${filename_len}d - ${nname_file} $(( number_of_files - 1 )) 3 | split_version_3 1 1 + JOT "%0${filename_len}d" ${nname_file} $(( number_of_files - 1 )) 3 | split_version_3 1 1 # set -- `hexdump -n 8 -v -e '" " 1/4 "%u"' ${file}` # tail -c +$(( $2 + 1 )) ${file} # done | tr '\n\0' '\t\n' > 01_02_Flags_Nachname @@ -203,11 +203,11 @@ handle_format_version_3() { printf "done.\n" printf "Splitting decompress vname chunks into their columns ... " - jot -w "%0${filename_len}d" - ${vname_file} $(( number_of_files - 1 )) 3 | xargs cat | tr '\n\0' '\t\n' | tr -d '\377' > 03_Vorname + JOT "%0${filename_len}d" ${vname_file} $(( number_of_files - 1 )) 3 | xargs cat | tr '\n\0' '\t\n' | tr -d '\377' > 03_Vorname printf "done.\n" printf "Splitting decompress table file chunks into their columns ... " - jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3 | split_version_3 4 0 + JOT "%0${filename_len}d" ${table_file} $(( number_of_files - 1 )) 3 | split_version_3 4 0 # for file in `jot -w %0${filename_len}d - ${table_file} $(( number_of_files - 1 )) 3`; do # # Offset into first table entry tells us how many # # fields are in table file @@ -300,11 +300,11 @@ handle_format_version_4() { printf "done.\n" printf "Splitting decompressed chunks into their columns (11 total) ... 1, " - jot -w "file_%05X" - 0 $(( rows - 1 )) 11 | xargs cat | xxd -ps -c1 > column_0 + JOT "file_%05X" 0 $(( rows - 1 )) 11 | xargs cat | xxd -ps -c1 > column_0 for col in 1 2 3 4 5 6 7 8 9 10; do printf "%d, " $(( col + 1 )) - jot -w "file_%05X" - ${col} $(( rows - 1 )) 11 | xargs cat | tr '\n\0' '\t\n' > column_${col} + JOT "file_%05X" ${col} $(( rows - 1 )) 11 | xargs cat | tr '\n\0' '\t\n' > column_${col} done printf "done.\n" @@ -374,5 +374,17 @@ tidy_streetnames () { rm "${streets}".bak } +# JOT +JOT () { + case `uname -s` in + *BSD|Darwin) + jot -w "$1" - "$2" "$3" "$4" + ;; + Linux) + seq -f "$1" "$2" "$4" "$3" + ;; + esac +} + # After function definitions, main() can use them main "$@" -- cgit v1.2.3