1837983 Members
3350 Online
110124 Solutions
New Discussion

64bits files

 
SOLVED
Go to solution

64bits files

Hello,

Does anyone know a command that would list all 64bits file under my Unix box (HP-UX). All new files are created 64 bits, but need to know wich one are 64bits or still 32bits.

Tkx!
4 REPLIES 4
Pete Randall
Outstanding Contributor

Re: 64bits files

The "file" command should tell you:

file /stand/vmunix
/stand/vmunix: ELF-64 executable object file - PA-RISC 2.0 (LP64)


Pete

Pete

Re: 64bits files

It does not list all 64bits files! Here is what I get :

# file /stand/vmunix
/stand/vmunix: ELF-64 executable object file - PA-RISC 2.0 (LP64)
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: 64bits files

You need to combine the find command with the file command. The idea is that we will look for all regular files with an execution bit set and then exclude those which are text (shell, perl, awk) and finally send those files which pass these filters through a last file command.

Start by cd'ing to the desired starting directory. It will descend from there.

#!/usr/bin/sh

find . -type f \( -perm -100 -o -perm -010 -o -perm 001 \) | while read X
do
file "${X}" | grep -q -i "text"
RSLT=${?}
if [[ ${RSLT} -ne 0 ]]
then
file "${X}" | grep -q -i "ELF-64"
RSLT=${?}
if [[ ${RSLT} -eq 0 ]]
then
echo "${X} is 64-bit"
else
echo "${X} is 32-bit"
fi
fi
done

Man find, file, grep for details.
If it ain't broke, I can fix that.

Re: 64bits files

Tks, it is exactlly what I needed.

Stephane!