fork download
  1. #!/bin/bash
  2.  
  3. # ideone boilerplate - we can't write files in the home directory;
  4. # so create a temporary directory for our files instead
  5. t=$(mktemp -d -t ideone.XXXXXXXXXXXX) || exit
  6. trap 'rm -rf "$t"' ERR EXIT
  7. cd "$t"
  8.  
  9. cat <<\: >a.txt
  10. 12
  11. 23
  12. 45
  13. 56
  14. :
  15.  
  16. awk 'NR>1 { close(f) }
  17. { f=++n ".txt"; print >f }' a.txt
  18.  
  19. tail [1-9]*.txt
Success #stdin #stdout 0.01s 5412KB
stdin
Standard input is empty
stdout
==> 1.txt <==
12

==> 2.txt <==
23

==> 3.txt <==
45

==> 4.txt <==
56