A regular file is one type of file that may be stored in a file system. It is called "regular" primarily to distinguish it from other special types of files.
When data is read from or written to a regular file, the kernel performs that action according to the rules of the filesystem. For instance, writes may be delayed, journaled, or subject to other special operations.
Linux file types
|Type name||Symbolic name||Bitmask|
|Block special file||S_IFBLK||0060000|
|FIFO (named pipe)||S_IFIFO||0010000|
How can I tell if a file is regular?
test -f /etc/passwd; echo $? # check for regular file, echo exit status of test
test -f /etc; echo $? # directories are not regular files, so test fails
file="/etc/passwd"; # assign filename, enclosed in "", to variable named file if test -f "$file"; # reference its value with $. Enclose expansion in "" then # this part will run if test returns 0 echo "$file is a regular file."; else # this part will run if test returns anything else echo "$file is not a regular file, or does not exist."; fi
/etc/passwd is a regular file.
You can also check a file's type with stat:
File: /etc/passwd Size: 2234 Blocks: 8 IO Block: 4096 regular file Device: 801h/2049d Inode: 132814 Links: 1 Access: (0644/-rw-r--r--) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-07-06 08:45:49.960000000 -0400 Modify: 2018-03-14 23:46:25.048004001 -0400 Change: 2018-03-14 23:46:25.052004001 -0400 Birth: -