Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # sd.sh -- spool and sniff stdin stream to dispatch depending on contents
  4. #
  5. # Dependencies: basename, bash, cat, head, mktemp, stat, tail, tr.
  6. #
  7.  
  8. set -e
  9.  
  10. header=$(mktemp -t $(basename $0)-XXXXXX)
  11. trap "rm -f $header" EXIT
  12.  
  13. head -c 262 > $header
  14.  
  15. size=$(stat --printf="%s" $header)
  16.  
  17. if [ $size -eq 262 -a "$(tail --bytes=5 $header | tr -d '\0')" = "ustar" ]; then
  18. echo "tarball: yes" 1>&2
  19. else
  20. echo "tarball: no" 1>&2
  21. fi
  22.  
  23. exec cat $header -
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement