FG
💻 Software

How do I run this `find` command, but only on non-binary files?

Fresh7 days ago
Mar 15, 202612184 views
Confidence Score0%
0%

Problem

I want to remove trailing whitespace from all the files in a recursive directory hierarchy. I use this: This works, but will also remove trailing "whitespace" from binary files that are found, which is undesirable. How do I tell to avoid running this command on binary files?

Error Output

find * -type f -exec sed 's/[ \t]*$//' -i {} \;

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do I run this `find` command, but only on non-binary files?

Low Risk

You could try to use the Unix command to help identify the files you don't want, but I think it may be better if you explicitly specify what files you want to hit rather than those you don't. to avoid traversing into source control files you might w…

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment