1819801 Members
3037 Online
109607 Solutions
New Discussion юеВ

Find file types

 
SOLVED
Go to solution
jerry1
Super Advisor

Find file types

Does anyone have a script already that will
find files of types .mov .wav , etc....
that users should not have in their UNIX home
directory?

Also, what are the bad file types now a days?

I'm using something like:

find . -type f | egrep "\.mov$|\.wav$|\.au$"

5 REPLIES 5
Ivan Krastev
Honored Contributor
Solution

Re: Find file types

You can use :

find . \( -name "*.wav" -o -name "*.mov" -o -name "*.au" \) -print

regards,
ivan
spex
Honored Contributor

Re: Find file types

Hi,

# find /home \( -name '*.mov' -o -name '*.wav' -o -name '*.au' \) -type f

"Bad files" are whatever you classify as such. You might want to add .avi, .mp3, and .ogg to your list.

PCS
jerry1
Super Advisor

Re: Find file types

I should have mentioned that we do
manufacturing so there is no need to
have Movies, Sound files or any other
junk that comes from the Internet.
MS Word, MS Excel and any other work
related file extension are okay. e.g.

.tar
.xls
.txt
.
.
.
Bill Hassell
Honored Contributor

Re: Find file types

It's important to note that there are no file types in Unix, or more accurately, the PC-like extension on a file is meaningless in HP-UX. So a file like .mov or .wav won't do anything. There is no association between a portion of a filename and some application. So there is no such definition in HP-UX as a 'bad' file type. You can 'guess' a bit about the content of a file with the file command as in:

file /home/user1/*

If there are concerns about inappropriate use of the system, it is far better to remove shell access by replacing the shell with a menu program. The users can do the work they need but have no access to create or delete files except through the menu. And this menu program will deny any ftp access by these users due to the menu program.


Bill Hassell, sysadmin
Hein van den Heuvel
Honored Contributor

Re: Find file types

If is very hard to solve people / social problems through technology.

Locking users into a menu system is most secure of course.

A .wav, .avi, or .mpg file could simply be a
component to training / education / documentation and be legit business or it could be 'adult entertainment'.

If you are too obvious about looking for specific file types a modestly sophisticated user will just hide them by calling them 'bad files' .txt or .dat.
(of course that would move them from the realm of 'I did not know I was not supposed to' to 'knowingly going against the rules')

You may want to add a "-size +1000000" to weeds out little stuff.

in fact you may want to consider making size the driver: Anything above nnn kb is suspect unless type is ".dbf" ".dat"...

Also, several 'bad' files are self-identifying. Just read the first 100 bytes or so and look for large files, regardless of the name, and look for 'known' strings in known places.

Doesn't the 'file' tool have some useful heuristics built in?


fwiw,
Hein.