Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software
User Name
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.


  Search this Thread
Old 02-20-2018, 02:21 AM   #1
LQ Newbie
Registered: Apr 2006
Posts: 19

Rep: Reputation: 0
How to find zero filled files?


I've got a bunch of files, and I need to find those files in which every byte contains 00 or $FF.

I've been searching and I've found only solutions to find zero sized files, but that's a different situation. The files I'm trying to find can have any size (i.e.: 279 bytes) but every byte inside the file contains a 0.

Do you know any program that can do that search?

I'd need either:
- A program that check the contents of every file on a given path and give me those files that are filled with zeroes.
- A program that sums the contains of every file on a given path, so I can find those files with a sum of 0 and look if they're filled with zeroes or not (crc32, md5 and sha checksums can not be used).


Last edited by Zup; 02-20-2018 at 02:28 AM.
Old 02-20-2018, 02:37 AM   #2
LQ Guru
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,624

Rep: Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499Reputation: 3499
probably exists, but I would rather try to implement it. Which language do you prefer?
Old 02-20-2018, 02:57 AM   #3
Senior Member
Registered: Mar 2016
Location: Harrow, UK
Distribution: Debian, Crux, LFS, AntiX
Posts: 2,477
Blog Entries: 6

Rep: Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204Reputation: 1204
For text files, you can do it with a simple awk script, looking for something like ^0*$ and printing "OK" if all the lines match. But that wouldn't work if some of your files are binary.
Old 02-20-2018, 03:44 AM   #4
Registered: Apr 2017
Posts: 45

Rep: Reputation: Disabled
grep -obUaPe '^\x00+$|^\xff+$' -r --include=*

Last edited by BudiKusasi; 02-20-2018 at 03:46 AM.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using find command to find files with an ACL set JockVSJock Linux - Newbie 2 12-14-2017 12:55 AM
root filled w/ 0 byte files very fast geckobub Linux - Newbie 4 01-10-2017 10:17 PM
fsck.ext4 zero-filled Files on a lvm-partition because of dying drive DrBenzo Linux - Newbie 5 01-24-2014 08:44 AM
find hidden files from wild card path using 'find' nagendrar Linux - Newbie 5 10-13-2011 11:48 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 06:55 PM > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:27 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration