HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: determine file type and excel file
Operating System - HP-UX
1833679
Members
4289
Online
110062
Solutions
Forums
Categories
Company
Local Language
back
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
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
12-14-2004 11:05 PM
12-14-2004 11:05 PM
determine file type and excel file
Hello,
I would like to know how to configure /etc/magic file or anything else to recognize excel format file with file command.
A developper needs to write a script to check format file before importing data in Oracle.
With command file, he has only "data" information.
He uses "strings" command now but I would like to know if there is another solution.
Thanks
Laurent
I would like to know how to configure /etc/magic file or anything else to recognize excel format file with file command.
A developper needs to write a script to check format file before importing data in Oracle.
With command file, he has only "data" information.
He uses "strings" command now but I would like to know if there is another solution.
Thanks
Laurent
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2004 11:39 PM
12-14-2004 11:39 PM
Re: determine file type and excel file
I just looked at an excel file with 'textpad' which goes into data mode for binary files. I see a 'Microsoft Excel' string somewhere in the middle (offset 0x12A0) of my small test file, but I see no easy (binary) pointer to that location early in the file. Nor do I see an 'easy = text' marker in the first bytes.
So I suspect you'll be stuck with strings.
Actually... why not just 'grep'? That would be a little faster. You don't realy want to know what it looks like, just whether it is ter no? I suppose you could have false positives, like someone putting 'how to recognize a Microsoft Excel file' in a text, but you porbably know enough about your business context to evaluate / anticipate that. Perhaps a simple file first to tell you it is just data, not a recognizable other format.
And you are sure you can not simple tell through a file name?
Hein.
So I suspect you'll be stuck with strings.
Actually... why not just 'grep'? That would be a little faster. You don't realy want to know what it looks like, just whether it is ter no? I suppose you could have false positives, like someone putting 'how to recognize a Microsoft Excel file' in a text, but you porbably know enough about your business context to evaluate / anticipate that. Perhaps a simple file first to tell you it is just data, not a recognizable other format.
And you are sure you can not simple tell through a file name?
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2004 12:19 AM
12-15-2004 12:19 AM
Re: determine file type and excel file
Hi,
i would go like this:
every excel file shuld hace an extension .xls -> first check
every excel file should start with thiese exhadecimal values: "320 317 021 340"
You may write a test script like:
#!/sbin/sh
TEST=$(dd if=$1 count=4 bs=1 2>/dev/null| xd -t c | grep "320 317 021 340" | wc -l )
if [ $TEST -gt 0 ]
then
echo "It's excel!!"
fi
Tested on my server, it works..
HTH,
Massimo
i would go like this:
every excel file shuld hace an extension .xls -> first check
every excel file should start with thiese exhadecimal values: "320 317 021 340"
You may write a test script like:
#!/sbin/sh
TEST=$(dd if=$1 count=4 bs=1 2>/dev/null| xd -t c | grep "320 317 021 340" | wc -l )
if [ $TEST -gt 0 ]
then
echo "It's excel!!"
fi
Tested on my server, it works..
HTH,
Massimo
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP