What you also could do is filter output of hexdump of thefirst several bytes to get the file signature.
$ hexdump -C -n 16 ./Pictures/NOTEBOOKS/8.jpg 00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 |......JFIF.....d| 00000010 Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Visit Stack ExchangeStack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
Explore Stack Internal What you also could do is filter output of hexdump of thefirst several bytes to get the file signature.
$ hexdump -C -n 16 ./Pictures/NOTEBOOKS/8.jpg 00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 |......JFIF.....d| 00000010 What you also could do is filter output of hexdump of thefirst several bytes to get the file signature.
$ hexdump -C -n 16 ./Pictures/NOTEBOOKS/8.jpg 00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 |......JFIF.....d| 00000010 You're slightly wrong in your assumptions. Block special files are things like hard drive partition, memory devices. For instance, the main partition of my hard-drive is /dev/sda1. The test's (aka [) -b flag will work for that, but it won't work for a picture file, which is considered a regular file.
$ test -b ./Pictures/NOTEBOOKS/8.jpg && echo "It's a block device" || echo "Not a block device" Not a block device $ test -b /dev/sda1 && echo "It's a block device" || echo "Not a block device" It's a block device Character devices are things like tty and serial consoles. For instance:
$ test -c /dev/tty1 && echo "It's a character device" || echo "Not a character dev" It's a character device And stat can tell you pretty much this same information, just in text form instead of exit status like test does:
$ stat --printf "%n\t%F\n" /dev/tty1 /dev/sda1 ./mytext.txt ./Pictures/NOTEBOOKS/8.jpg /dev/tty1 character special file /dev/sda1 block special file ./mytext.txt regular file ./Pictures/NOTEBOOKS/8.jpg regular file What you should be doing is using file command, and checking its output:
$ file ./Pictures/NOTEBOOKS/8.jpg ./Pictures/NOTEBOOKS/8.jpg: JPEG image data, JFIF standard 1.02, aspect ratio, density 100x100, segment length 16, baseline, precision 8, 750x750, frames 3 $ file /dev/sda1 /dev/sda1: block special (8/1) $ file mytext.txt mytext.txt: ASCII text What you also could do is filter output of hexdump of thefirst several bytes to get the file signature.
$ hexdump -C -n 16 ./Pictures/NOTEBOOKS/8.jpg 00000000 ff d8 ff e0 00 10 4a 46 49 46 00 01 02 00 00 64 |......JFIF.....d| 00000010