The following was removed from Chapter 10: “The find Command”.
Print find
Results into a File
find -fprint
Every time we’ve used find
, we have assumed that the -print
option isn’t necessary because it’s on by default. If you want to print to a file instead of the terminal, you use the -fprint
option, followed by the name of the file you want to create.
$ find . ! \( -name "*mp*" -o -name "*ogg" -o -name "*flac" -o -type d \) -fprint non_music_files.txt
$ cat non_music_files.txt
./Folk/Joan_Baez/Joan_Baez_-_Imagine.m3u
./500_Greatest_Singles/singles.txt
./Blues/Muddy_Waters/Best_Of.m3u
./Blues/Robert_Johnson/Hellhound_On_My_Trail.MP3
./Blues/Johnny_Winter/Johnny_Winter.m3u
[Results truncated for length]
You can then use these results in scripts, or send them to a printer if that would be helpful.