URIFIND(1p)

πŸ“¦
this version Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble

✨ URIFIND(1p) ✨

ok so bestie, this is urifind β€” a little Perl script from the User Contributed Perl Documentation corner of the universe, and it's literally just here to do one job and do it cute. πŸ’–


🌸 NAME 🌸

urifind β€” find URIs in a document and dump them to STDOUT. that's the whole personality. no cap. πŸ’…


πŸŽ€ SYNOPSIS πŸŽ€

$ urifind file

πŸ¦‹ DESCRIPTION πŸ¦‹

so urifind is a simple script. like, simple simple. it finds URIs in one or more files (it's using URI::Find under the hood, bestie, respect the pipeline πŸ‘‘) and it outputs them to STDOUT. that's it. that's the entire arc. no plot twist. 🫢

want all the URIs in file1? say less:

$ urifind file1

want the URIs from multiple files? just list them as arguments, one after another, like a lil lineup:

$ urifind file1 file2 file3

and here's the part where it gets cozy β€” urifind will read from STDIN if you give it no files at all, or if you specify a filename of -. so you can pipe straight into it:

$ wget http://www.boston.com/ -O - | urifind

when multiple files are listed, urifind prefixes each URI it finds with the file it came from. so you always know who said what. πŸ’¬

$ urifind file1 file2
file1: http://www.boston.com/index.html
file2: http://use.perl.org/

you can turn that prefixing ON for a single file too, with the -p ("prefix") switch:

$urifind -p file3
file1: http://fsck.com/rt/

and you can turn it OFF for multiple files with the -n ("no prefix") switch:

$ urifind -n file1 file2
http://www.boston.com/index.html
http://use.perl.org/

ok now. by default, URIs show up in the order they were found β€” vibes order, discovery order, the order the universe intended. but if you want them sorted ascii-betically, hit the -s ("sort") option. and if you want them reverse sorted, that's the -r ("reverse") flag β€” and heads up, -r implies -s, it's a package deal bestie. πŸ”₯

$ urifind -s file1 file2
http://use.perl.org/
http://www.boston.com/index.html
mailto:webmaster@boston.com

$ urifind -r file1 file2
mailto:webmaster@boston.com
http://www.boston.com/index.html
http://use.perl.org/

and finally, urifind supports limiting the returned URIs by scheme, or by arbitrary pattern β€” using the -S option (for schemes, duh πŸ’…) and the -P option. and the best part? both -S and -P can be specified multiple times. stack 'em, queen.

$ urifind -S mailto file1
mailto:webmaster@boston.com

$ urifind -S mailto -S http file1
mailto:webmaster@boston.com
http://www.boston.com/index.html

-P takes an arbitrary Perl regex. ngl, it might need to be protected from the shell, so quote it like the icon it is:

$ urifind -P 's?html?' file1
http://www.boston.com/index.html

$ urifind -P '\.org\b' -S http file4
http://www.gnu.org/software/wget/wget.html

add a -d and urifind will dump the regexes generated from -S and -P over to STDERR. -D does the same exact thing but exits immediately after. dump and dip. πŸ™ˆ

$ urifind -P '\.org\b' -S http -D
$scheme = '^(\bhttp\b):'
@pats = ('^(\bhttp\b):', '\.org\b')

and to remove duplicates from the results? that's the -u ("unique") switch. no repeats, only originals. ⭐


πŸ’… OPTION SUMMARY πŸ’…

  • -s β€” sort results.
  • -r β€” reverse sort results (implies -s).
  • -u β€” return unique results only.
  • -n β€” don't include filename in output.
  • -p β€” include filename in output (0 by default, but 1 if multiple files are included on the command line).
  • -P $re β€” print only lines matching regex '$re' (may be specified multiple times).
  • -S $scheme β€” only this scheme (may be specified multiple times).
  • -h β€” help summary.
  • -v β€” display version and exit.
  • -d β€” dump compiled regexes for -S and -P to STDERR.
  • -D β€” same as -d, but exit after dumping.

πŸ‘‘ AUTHOR πŸ‘‘

darren chamberlain <darren@cpan.org>


(C) 2003 darren chamberlain

this library is free software; you may distribute it and/or modify it under the same terms as Perl itself. πŸ’œ


🌈 SEE ALSO 🌈

URI::Find


ok bestie that's the whole page, mwah. πŸ’– this lil gem is from perl v5.34.0, dated 2022-06-28, and it's filed under URIFIND(1p). go find some URIs. slay. βœ¨πŸ¦‹πŸŽ€

πŸ“¦ where this page comes from