fork download
  1. #!/bin/bash
  2.  
  3. # ideone boilerplate: run in temp dir
  4. t=$(mktemp -d -t ideone.XXXXXXXX) || exit
  5. trap 'rm -rf "$t"' ERR EXIT
  6. cd "$t"
  7.  
  8. yes one | head -n 10 >base
  9. nl base >1_chr_3.txt
  10. sed s/one/two/ base >2_chr_3.txt
  11. sed s/one/three/ base >3_chr_3.txt
  12. sed s/one/four/ base >4_chr_3.txt
  13.  
  14. ppaste () {
  15. case $# in
  16. 1|2) paste -d ' ' "$@";;
  17. *) local first=$1
  18. shift
  19. paste -d ' ' "$first" <(ppaste "$@");;
  20. esac
  21. }
  22.  
  23. echo '** plain paste'
  24. paste -d ' ' *_chr_3.txt
  25.  
  26. echo '** recursive function'
  27. ppaste *_chr_3.txt
Success #stdin #stdout 0.02s 5688KB
stdin
Standard input is empty
stdout
** plain paste
     1	one two three four
     2	one two three four
     3	one two three four
     4	one two three four
     5	one two three four
     6	one two three four
     7	one two three four
     8	one two three four
     9	one two three four
    10	one two three four
** recursive function
     1	one two three four
     2	one two three four
     3	one two three four
     4	one two three four
     5	one two three four
     6	one two three four
     7	one two three four
     8	one two three four
     9	one two three four
    10	one two three four