Re: I need grep . help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx
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@xxxxxxxxxxxxxxxxxxxxxxx
Do not reply to spam, report it: https://pagure.io/fedora-infrastructure/new_issue
[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux