1

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

5
  • 3
    What exactly is that /dev/null in the end supposed to mean? Commented Sep 27, 2016 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
    Commented Sep 27, 2016 at 19:13
  • @ByteCommander I adedd an explanation for that. Commented Sep 27, 2016 at 19:18
  • @Munir Yes, mistake in writing the code here again, fixed. Commented Sep 27, 2016 at 19:18
  • 2
    It must be 2>/dev/null in the end to hide stderr messages. Commented Sep 27, 2016 at 19:21

1 Answer 1

2

Just:

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
2
  • In my case, there is a need of /dev/null but change it only to 2>/dev/null. Commented Sep 27, 2016 at 19:25
  • 1
    I just try to guess your misstake ;) Commented Sep 27, 2016 at 19:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .