diff options
| author | Dirk Engling <erdgeist@erdgeist.org> | 2014-02-07 21:21:44 +0100 |
|---|---|---|
| committer | Dirk Engling <erdgeist@erdgeist.org> | 2014-02-07 21:21:44 +0100 |
| commit | b8732d1deeca54d1200d7dccefa04bee2b8ca3aa (patch) | |
| tree | e6adc9c84808204b0b16ecf368b7a38482a74a4f /src | |
| parent | b2714458565cac46ec1a79311fec5d4baef415e2 (diff) | |
Eliminate repeating invocation of shell tools by using the pipe more efficently
This reduces the number of forks and saves more than 50% of the conversion time
Diffstat (limited to 'src')
| -rwxr-xr-x | src/makecolumns.sh | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/makecolumns.sh b/src/makecolumns.sh index 6f6f9d9..b41b454 100755 --- a/src/makecolumns.sh +++ b/src/makecolumns.sh | |||
| @@ -202,17 +202,12 @@ handle_new_format() { | |||
| 202 | numfiles=`find . -name file_\* | wc -l` | 202 | numfiles=`find . -name file_\* | wc -l` |
| 203 | printf "done.\n" | 203 | printf "done.\n" |
| 204 | 204 | ||
| 205 | printf "Splitting decompressed chunks into their columns (11 total) ... " | 205 | printf "Splitting decompressed chunks into their columns (11 total) ... 0, " |
| 206 | for column in `jot - 0 10 1`; do | 206 | for file in `jot - 0 $(( numfiles - 1 )) 11`; do printf "file_%05X " ${file}; done | xargs cat | xxd -ps -c1 > column_0 |
| 207 | |||
| 208 | for column in `jot 10`; do | ||
| 207 | printf "%d, " $column | 209 | printf "%d, " $column |
| 208 | for file in `jot - ${column} $(( numfiles - 1 )) 11`; do | 210 | for file in `jot - ${column} $numfiles 11`; do printf "file_%05X " ${file}; done | xargs cat | tr '\n\0' '\t\n' > column_${column} |
| 209 | acton=`printf file_%05X ${file}` | ||
| 210 | if [ ${column} = 0 ]; then | ||
| 211 | xxd -ps -c1 ${acton} >> column_0; | ||
| 212 | else | ||
| 213 | tr '\n\0' '\t\n' < ${acton} >> column_${column}; | ||
| 214 | fi | ||
| 215 | done; | ||
| 216 | done | 211 | done |
| 217 | printf "done.\n" | 212 | printf "done.\n" |
| 218 | 213 | ||
