how can i detect the file typ of a file ?
the command "file" is not so useful because it shows only strings (in the example in GERMAN), here some examples :
Test for normal file with ASCII strings:
file with size zero:
create of file: touch touch-zero
test of file: file touch-zero
output of file: touch-zero: leer
file with one line:
create of file: echo line > touch-one-line
test of file: file touch-one-line
output of file: touch-one-line: Ascii-Text
character device-file :
test of file: file /dev/null
output of file: /dev/null: zeichenorientiert (3/2)
test of file: file /dev/async
output of file: /dev/async: zeichenorientiert (101/0)
test of file: file /dev/rac/bt6lto3picker
output of file: /dev/rac/bt6lto3picker: zeichenorientiert (231/11534336)
test of file: file /dev/vg00/rlvol1
output of file: /dev/vg00/rlvol1: zeichenorientiert (64/1)
block device-file :
test of file: file /dev/vg00/lvol1
output of file: /dev/vg00/lvol1: blockorientiert (64/1)
so i think it is better to check the file typ with the command "test" :
test -f , test -b , test -c and so on.
but how can i detect if the file exists ( at that time i don't know the file typ)
test -s is not the recommended way ?
test -s /dev/null => isn't true
test -s touch-zero => isn't true
test -s touch-one-line => is true
after the first check, i can begin to check the file typ of the file.
i think it is better to create a little script to to cover the exceptions.
does anyone have some useful tips.
regards,Tom