- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: File command
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
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
02-13-2001 07:57 AM
02-13-2001 07:57 AM
File command
How does a file command work?. Will it open file for reading? If it opens why the acccess time doesn't change?
Thanks in Advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:18 AM
02-13-2001 08:18 AM
Re: File command
Direct from the man page:
==
file performs a series of tests on each file in an attempt to classify it. If file appears to be an ASCII file, file examines the first 512 bytes and tries to guess its language. If file is an executable a.out file, file prints the version stamp, provided it is greater than 0.
==
In short, the file command provides information about its type and version (binary) where possible.
Hope this helps. Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:28 AM
02-13-2001 08:28 AM
Re: File command
'file' opens the file(s) given as arguments, performs a series of test in an attempt to classify them.
For files having a magic number, file uses /etc/magic.
As the file is opened, the access time is modified. If you type 'ls -lutr' in a directory where you issued the file command, you'll see the last accessed file at the end.
(-u flag to reflect last access time instead of last modification)
Best regards,
Dan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:33 AM
02-13-2001 08:33 AM
Re: File command
The file command uses a file called 'magic' to map the contents of a sequence of bytes at or near the beginning of the file to the type of the file.
For example, if the first bytes of a file are '#!/usr/bin/perl', the file command decides that it is a perl script.
This works for binary files too, as they have a signature to identify them.
Have a look at the /etc/magic file, and you can see for yourself how it does the trick.
Hope this helps,
Rik.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:34 AM
02-13-2001 08:34 AM
Re: File command
Interesting, indeed. I too have read the man pages and would expect the last access date as returned by "ls -ul" to change -- it clearly doesn't. The inode timestamp (as returned by "ls -cl" DOES CHANGE. Perhaps 'file' is restoring the lastaccess timestamp after it reads the file (?).
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:36 AM
02-13-2001 08:36 AM
Re: File command
From the man page, it appears that the file is opened for reading regardless of whether it is ascii or binary.
I did a test and you are indeed right that the last access time is not updated even though the file is opened. ls -lu does not reflect the new access time when the file command is used.
My guess is that the "file" command "touch" the file back to its original access time.
Regards.
Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2001 08:42 AM
02-13-2001 08:42 AM
Re: File command
You're right. I should have checked instead of simply believing... !-(
'ls -lct' reflects the inode timestamp change
Regards
Dan