Skip to content

Instantly share code, notes, and snippets.

@Rotwang
Created January 4, 2017 19:55
Show Gist options
  • Save Rotwang/f34fa746762657ac4d6f07f95ab169c4 to your computer and use it in GitHub Desktop.
Save Rotwang/f34fa746762657ac4d6f07f95ab169c4 to your computer and use it in GitHub Desktop.
bartek@computingmachine:~$ cat wojtek
#!/usr/bin/env bash
wojtek="$(stat -L -c %f $1)"
case $((16#$wojtek >> 12)) in
1) echo FIFO ;;
2) echo Character dev ;;
4) echo Directory ;;
6) echo Block dev ;;
8) echo Regular file ;;
10) echo Symlink ;;
esac
bartek@computingmachine:~$ chmod +x wojtek
bartek@computingmachine:~$ ./wojtek /dev/sda
Block dev
bartek@computingmachine:~$ ./wojtek /dev/zero
Character dev
bartek@computingmachine:~$ ./wojtek /dev/std
stderr stdin stdout
bartek@computingmachine:~$ ./wojtek /dev/stdout
FIFO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment