0

In the output of wget --help I would like to quickly go to the place where the --header option is explained.

enter image description here

I try searching with less. man less explains:

/pattern
              Search  forward  in  the  file  for the N-th line containing the pattern.  N defaults to 1.  The pattern is a regular expression, as recognized by the regular
              expression library supplied by your system.  The search starts at the first line displayed (but see the -a and -j options, which change this).

Following this recommendation I try:

wget --help | less /header

but it causes an error:

/header: No such file or directory

What is wrong?

2

2 Answers 2

3

The less utility will try to open the file(s) listed as operands on the command line. There is no file called /header on your system. What you tried to do was to give the interactive command for searching for the string header, but this can't be done that way from the command line.

Any interactive less command can be given as an initial command for less to execute by prefixing it with + on the command line. So you could have done

wget --help | less '+/header'

See man less | less '+/ \+ ' for more info about that.

This happens to be equivalent to the other way of specifying a search pattern on the command line, -p pattern, but is more generic as adding an initial + applies to all interactive commands, while -p is specifically for specifying a search term.

wget --help | less -p 'header'
3

The /pattern command is used when you are inside less. To use that as a command line switch, use the -ppattern option. In this case, wget --help | less -pheader.

You must log in to answer this question.

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