I moved away from Ubuntu to Debian, and having a problem with my find now for searching tex files for the word masi. Code and its output

masi@masi:~$ find -L "/home/masi/" -xtype f \
    -name "*.tex" -exec fgrep -l 'masi' {} + /dev/null

find: paths must precede expression: /dev/null
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]
  • /dev/null is necessary in the second command set because we are using find -L, since we want to include all symlinks and go them through and not exclude anything in the search. Thread where the motivation for the use here about How to Avoid Many Levels of symlinks with this find?

As one-liner

find -L "/home/masi/" -xtype f -name "*.tex" -exec fgrep -l 'masi' {} + /dev/null

OS: Debian 8.5
Linux kernel: 4.6 of backports
Hardware: Asus Zenbook UX303UA
Related: find command of my haetex script in the thread How to search .tex files?
Find: find (GNU findutils) 4.4.2
Fgrep: grep (GNU grep) 2.20

  • 3
    What exactly is that /dev/null in the end supposed to mean? – Byte Commander Sep 27 '16 at 19:11
  • 1
    Also, your fgrep invocation is missing the search string. Should be something like fgrep -l 'some string' {} +. I can't understand what the /dev/null is supposed to do here. – Munir Sep 27 '16 at 19:13
  • @ByteCommander I adedd an explanation for that. – Léo Léopold Hertz 준영 Sep 27 '16 at 19:18
  • @Munir Yes, mistake in writing the code here again, fixed. – Léo Léopold Hertz 준영 Sep 27 '16 at 19:18
  • 2
    It must be 2>/dev/null in the end to hide stderr messages. – Byte Commander Sep 27 '16 at 19:21


find -L /home/masi/ -xtype f -name "*.tex" -exec fgrep -l 'masi' {} +

no need /dev/null as far as {} is the place holder for the processed file(s)

If you try to hide the error output, use it like this :

command 2>/dev/null
  • In my case, there is a need of /dev/null but change it only to 2>/dev/null. – Léo Léopold Hertz 준영 Sep 27 '16 at 19:25
  • 1
    I just try to guess your misstake ;) – Gilles Quenot Sep 27 '16 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.