Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is a regular file on unix

Tags:

file

unix

manpage

I saw the man page of test.

where the below is mentioned.

-e  pathname
    True if pathname resolves to a file that exists. False if pathname cannot be resolved.
-f  pathname
    True if pathname resolves to a file that exists and is a regular file. False if pathname cannot be resolved, or if pathname resolves to a file that exists but is not a regular file.

the -f flag says True if pathname resolves to a file that exists and is a regular file Could anybody please tell what is a regular file and what is not a regular file.

like image 840
Vijay Avatar asked Jul 28 '11 11:07

Vijay


2 Answers

Non-regular files are devices, pipes, sockets... try [ -f /dev/tty0 ], for example. Symlinks are also non-regular, but they're resolved by test -f.

like image 134
Costi Ciudatu Avatar answered Nov 02 '22 03:11

Costi Ciudatu


They're text or binary data, called 'regular files' to distinguish them from other types like directories, symbolic links, sockets etc.

Take a look at http://en.wikipedia.org/wiki/Unix_file_types

like image 10
strmqm Avatar answered Nov 02 '22 02:11

strmqm