- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: file typ of a file
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2007 08:11 PM
07-30-2007 08:11 PM
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.
does anyone have some useful tips
regards,Tom
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2007 08:32 PM
07-30-2007 08:32 PM
Re: file typ of a file
test -r
HeL
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2007 08:37 PM
07-30-2007 08:37 PM
Re: file typ of a file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2007 08:42 PM
07-30-2007 08:42 PM
Re: file typ of a file
Check the manpage of ksh, especially the "Conditional Expressions" section.
there are a lot of test conditions for files.
Regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 02:19 AM
08-01-2007 02:19 AM
Re: file typ of a file
exists()
{
[ -n "${DEBUG}" ] && set -x
[[ -f $1 || -d $1 || -L $1 || -p $1 || -S $1 || -b $1 || -c $1 ]]
return $?
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-01-2007 01:27 PM
08-01-2007 01:27 PM
Re: file typ of a file
All you needed was:
[[ -a $1 ]]
This is a ksh or posix extension to test(1).