BackgroundI am managing a cellular interface. I have a bash script that is testing the interface. In question is the file located at /sys/class/net/wwan1/carrier where wwan1 is an unconfigured interface.This is obviously a special file, but I am unsure how to correctly test it in a bash script. See below...Consider the following:file /sys/class/net/wwan0/carrier # a good interface/sys/class/net/wwan0/carrier: ASCII textfile /sys/class/net/wwan1/carrier # an unconfigured interface/sys/class/net/wwan1/carrier: ERROR: cannot read `/sys/class/net/wwan1/carrier' (Invalid argument)Some cat data:$ cat /sys/class/net/wwan0/carrier # good interface1$ cat /sys/class/net/wwan1/carrier # unconfiguredcat: /sys/class/net/wwan1/carrier: Invalid argumentThis error from cat is the problem.The file located at /sys/class/net/wwan1/carrier is reported by ls however:$ cd /sys/class/net/wwan1$ ls -altotal 0drwxr-xr-x 4 root root    0 Dec 27 17:36 .drwxr-xr-x 3 root root    0 Dec 27 17:36 ..-r--r--r-- 1 root root 4096 Dec 28 20:24 addr_assign_type-r--r--r-- 1 root root 4096 Dec 28 20:24 address-r--r--r-- 1 root root 4096 Dec 28 20:24 addr_len-r--r--r-- 1 root root 4096 Dec 28 20:24 broadcast-r--r--r-- 1 root root 4096 Dec 28 18:57 carrierlrwxrwxrwx 1 root root    0 Dec 28 20:24 device -> ../../../1-1:1.10-r--r--r-- 1 root root 4096 Dec 28 20:24 dev_id-r--r--r-- 1 root root 4096 Dec 28 20:24 dormant-r--r--r-- 1 root root 4096 Dec 28 20:24 duplex-rw-r--r-- 1 root root 4096 Dec 28 20:24 flags-rw-r--r-- 1 root root 4096 Dec 28 20:24 ifalias-r--r--r-- 1 root root 4096 Dec 28 20:24 ifindex-r--r--r-- 1 root root 4096 Dec 28 20:24 iflink-r--r--r-- 1 root root 4096 Dec 28 20:24 link_mode-rw-r--r-- 1 root root 4096 Dec 28 20:24 mtu-rw-r--r-- 1 root root 4096 Dec 28 20:24 netdev_group-r--r--r-- 1 root root 4096 Dec 28 18:57 operstatedrwxr-xr-x 2 root root    0 Dec 28 20:24 power-r--r--r-- 1 root root 4096 Dec 28 20:24 speeddrwxr-xr-x 2 root root    0 Dec 28 20:24 statisticslrwxrwxrwx 1 root root    0 Dec 27 17:36 subsystem -> ../../../../../../../../../../class/net-rw-r--r-- 1 root root 4096 Dec 28 20:24 tx_queue_len-r--r--r-- 1 root root 4096 Dec 28 20:24 type-rw-r--r-- 1 root root 4096 Dec 27 17:36 ueventThe ProblemI am testing a variety of possible interface configurations and problems in a bash script. One of which is that the interface is unconfigured. I am probing /sys because I have found the output of ifconfig and ip to be unreliable.My QuestionHow can I test the value of the file /sys/class/net/wwan1/carrier in a bash if statement (the file itself being unreadable but present, i.e. this is an unconfigured interface? Here's what I have tried:if [[ -e /sys/class/net/wwan1/carrier ]]; then    echo Goodelse    echo BadfiI have also used the tests -b, -c, -f all of which fail to be able to distinguish between the 'readable' state of this file in /sys/class/net/wwan1/ - the 'bad' file, and /sys/class/net/wwan0/ - the 'good' file.EditThe -r and -s tests reports good in both cases, which is a problem since cat will fail in the first case.Edit stat output$ stat /sys/class/net/wwan0/carrier  File: `/sys/class/net/wwan0/carrier'  Size: 4096            Blocks: 0          IO Block: 4096   regular fileDevice: fh/15d  Inode: 5657        Links: 1Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)Access: 2015-12-28 17:01:06.976418548 +0000Modify: 2015-12-28 17:01:06.976418548 +0000Change: 2015-12-28 17:01:06.976418548 +0000 Birth: -and$ stat /sys/class/net/wwan1/carrier  File: `/sys/class/net/wwan1/carrier'  Size: 4096            Blocks: 0          IO Block: 4096   regular fileDevice: fh/15d  Inode: 6181        Links: 1Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)Access: 2015-12-28 18:57:37.876419704 +0000Modify: 2015-12-28 18:57:37.876419704 +0000Change: 2015-12-28 18:57:37.876419704 +0000 Birth: -
Help testing special file in `/sys/class/net/`
bash;networking;files