Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. fast_chr() {
  4. local __octal
  5. local __char
  6. printf -v __octal '%03o' $1
  7. printf -v __char \\$__octal
  8. REPLY=$__char
  9. }
  10.  
  11. function unichr {
  12. local c=$1 # Ordinal of char
  13. local l=0 # Byte ctr
  14. local o=63 # Ceiling
  15. local p=128 # Accum. bits
  16. local s='' # Output string
  17.  
  18. (( c < 0x80 )) && { fast_chr "$c"; echo -n "$REPLY"; return; }
  19.  
  20. while (( c > o )); do
  21. fast_chr $(( t = 0x80 | c & 0x3f ))
  22. s="$REPLY$s"
  23. (( c >>= 6, l++, p += o+1, o>>=1 ))
  24. done
  25.  
  26. fast_chr $(( t = p | c ))
  27. echo -n "$REPLY$s"
  28. }
  29.  
  30. ## test harness
  31. for (( i=0x10000; i<0x10100; i++ )); do
  32. touch ${WORK_MOUNT_POINT}/$(unichr $i)
  33. done
  34.  
  35. ######################################################################
  36.  
  37. df -l --output=pcent | sed 's/%//g' | grep -Eo '[0-9]{1,3}'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement