KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Unix 'file' command has a -0 option to output a null character after a filename. This is supposedly good for using with 'cut'. From man file : -0, --print0 Output a null character ‘\0’ after the end of the filename. Nice to cut(1) the output. This does not affect the separator which is still printed. (Note, on my Linux, the '-F' separator is NOT printed - which makes more sense to me.) How can you use 'cut' to extract a filename from output of 'file'? This is what I want to do: find . "*" -type f | file -n0iNf - | cut -d<null> -f1 where <null> is the NUL character. Well, that is what I am trying to do, what I want to do is get all file names from a directory tree that have a particular MIME type. I use a grep (not shown). I want to handle all legal file names and not get stuck on file names with colons, for example, in their name. Hence, NUL would be excellent. I guess non-cut solutions are fine too, but I hate to give up on a simple idea.
Tags (comma-separated)
Save Edits
Cancel