The Unix command 'file' has the -0 option to output the null character after the file name. This is supposed to be convenient for use with cut.
From man file
:
-0,
(Note: in my Linux, the separator '-F' is NOT printed, which makes more sense to me.)
How can you use 'cut' to extract a file name from the output of a 'file'?
This is what I want to do:
find . "*" -type f | file -n0iNf - | cut -d<null> -f1
where <null>
is the NUL character.
Well, this is what I'm trying to do, what I want to do is get all the file names from a directory tree with a specific MIME type. I am using grep (not shown).
I want to process all legal file names and not get stuck file names with colons, for example, on their behalf. Consequently, NUL will be excellent.
I think the futile solutions are great too, but I don't want to give up a simple idea.
source share