ToddAndMargo via users wrote:
> Hi All,
> 
> I am literally looking for "9.4.5" with grep.  Grep thinks
> I want the dots to be wild cards.  What am I doing wrong?
> 
> $ curl -L "https://sourceforge.net/projects/crystaldiskinfo/files/"; -o - |
> grep -i '9.4.5'

To take another tangent, the curl `-o -` option can be
dropped.  The default output _is_ stdout, so specifying it
here is needless cruft.

    -o, --output <file>
        Write output to <file> instead of stdout. [...]

I'd suggest using `-sS` as well when piping, to avoid the
progress and other status output.

    -s, --silent
        Silent or quiet mode. Do not show progress meter or
        error messages. Makes Curl mute. It will still
        output the data you ask for, potentially even to the
        terminal/stdout unless you redirect it.

    -S, --show-error
        When used with -s, --silent, it makes curl show an
        error message if it fails.

Altogether, that makes the command shorter and the output a
little cleaner.

Of course, grepping for the version string in HTML output is
really never going to be clear.  There are likely better
ways to achieve the goal, whatever it may be.

One exception would be if the goal is to simply know that
there is a match, and then adding `-q` to the grep command
would be ideal.

Or adding the `-o` (`--only-matching`) option along with
`-m1` (`--max-count=1`) to only show one match.  In that
case, dropping the `-S` from curl avoids an error from curl
about writing the output when grep unceremoniously closes
the pipe.

But all that suggests that screen scraping HTML output is
almost never the ideal solution.

-- 
Todd

Attachment: signature.asc
Description: PGP signature

-- 
_______________________________________________
users mailing list -- users@lists.fedoraproject.org
To unsubscribe send an email to users-le...@lists.fedoraproject.org
Fedora Code of Conduct: 
https://docs.fedoraproject.org/en-US/project/code-of-conduct/
List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines
List Archives: 
https://lists.fedoraproject.org/archives/list/users@lists.fedoraproject.org
Do not reply to spam, report it: 
https://pagure.io/fedora-infrastructure/new_issue

Reply via email to