LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
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.

Notices


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

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


Hi

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).

Thanks.

Last edited by Zup; 02-20-2018 at 01:28 AM.
 
Old 02-20-2018, 01:37 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,842

Rep: Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308Reputation: 7308
probably exists, but I would rather try to implement it. Which language do you prefer?
 
Old 02-20-2018, 01:57 AM   #3
hazel
LQ Guru
 
Registered: Mar 2016
Location: Harrow, UK
Distribution: LFS, AntiX, Slackware
Posts: 7,573
Blog Entries: 19

Rep: Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452Reputation: 4452
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, 02:44 AM   #4
BudiKusasi
Member
 
Registered: Apr 2017
Distribution: Artix
Posts: 345

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

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


Reply



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 6 10-22-2021 07:31 AM
root filled w/ 0 byte files very fast geckobub Linux - Newbie 4 01-10-2017 09:17 PM
fsck.ext4 zero-filled Files on a lvm-partition because of dying drive DrBenzo Linux - Newbie 5 01-24-2014 07:44 AM
find hidden files from wild card path using 'find' nagendrar Linux - Newbie 5 10-13-2011 10:48 PM
Find/grep/wc command to find matching files, print filename and word count dbasch Linux - Newbie 10 09-14-2009 05:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

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