You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Lf assumes that a file containing '\U+0000' is a binary file.
in shell script. we can not do the same directly with grep,
But we can print file in hex then check if there are 0000.
Im using lf on android also, there is no hexdump provided by toybox, but there is base64.
By running
printf'\0'| base64
printf'\0\0'| base64
We can know that the pattern that NUL character base64 encoded is 'AA'.
So we can check if a file is binary in this way
if base64 "$1"| grep -q AA;thenecho"Assume Binary file"elseecho"Assume textual file"fi
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Lf assumes that a file containing '\U+0000' is a binary file.
in shell script. we can not do the same directly with grep,
But we can print file in hex then check if there are 0000.
Im using lf on android also, there is no hexdump provided by toybox, but there is base64.
By running
We can know that the pattern that NUL character base64 encoded is 'AA'.
So we can check if a file is binary in this way
Beta Was this translation helpful? Give feedback.
All reactions