Shell script question
Anyone out there in Linode-land know of a (semi-)foolproof way of determining whether a path is a device file or not? For example:
- /dev/sda is a device file; and
- /var/tmp is not a device file.
Socket files (e.g., /var/run/php-fpm.sock) are not device files.
✓ Best Answer
Never mind… I think I found the answer. From man test (Doh!):
-b file True if file exists and is a block special file.
-c file True if file exists and is a character special file.
The devices I'm interested in are all character-special files (SATA/USB drives)… I'm working on unifying two shell scripts that do backups -- one to files on USB drives (home use) and the other to files on Linode block storage (Linode use)…so I only have to maintain one.