pastebin - collaborative debugging tool
nrubsig.kpaste.net RSS


makeseqtree1 - build a POSIX Makefile which generates the number sequence 1...n in small chunks
Posted by Anonymous on Wed 28th Feb 2024 15:08
raw | new post
modification of post by Anonymous (view diff)

  1. #!/bin/ksh93
  2.  
  3. #
  4. # makeseqtree1 - build a POSIX Makefile which generates the
  5. # number sequence 1...n in small chunks
  6. #
  7. # This is intended to be a filesystem test
  8. #
  9.  
  10. #
  11. # Written by Roland Mainz <roland.mainz@nrubsig.org>
  12. #
  13.  
  14. #
  15.  
  16. # leaf function
  17. # ToDo: write function for branches which calls "make_seq_tree_leaf"
  18. function make_seq_tree_leaf
  19. {
  20.         set -o nounset
  21.         compound c
  22.  
  23.         typeset c.fp=$1 # prefix
  24.         integer c.seqstart=$2
  25.         integer c.seqincrement=$3
  26.         integer c.seqend=$4
  27.  
  28.         integer c.i
  29.         integer c.s
  30.         integer c.e
  31.         typeset c.cat_files=''
  32.  
  33.         for (( c.i=c.seqstart ; c.i < c.seqend ; )) ; do
  34.                 (( c.s=c.i , c.e=c.i+c.seqincrement ))
  35.                 printf '%sseq%d_%d:\n' "${c.fp}" c.s c.e
  36.                 printf '\tseq %d 1 %d >"%sseq%d_%d"\n' c.s c.e "${c.fp}" c.s c.e
  37.                 c.cat_files+="$(printf ' %sseq%d_%d' "${c.fp}" c.s c.e)"
  38.                 (( c.i=c.e ))
  39.         done
  40.        
  41.         printf '%s: %s\n' "${c.fp}" "${c.cat_files}"
  42.         printf '\tcat %s\n' "${c.cat_files}"
  43.  
  44.         return 0
  45. }
  46.  
  47. make_seq_tree_leaf 'xxx0_50' 0 10 50
  48. make_seq_tree_leaf 'xxx51_100' 1 10 100
  49.  
  50. printf 'all: xxx0_50 xxx51_100\n'
  51.  
  52. # EOF.

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at