
urlview Command in Linux
In many Unix and Linux environments, you often work with plain-text files, mailing lists, log files, or even command output that contains embedded web addresses (URLs). While modern graphical browsers make it easy to click on hyperlinks, many Unix tools deliver text output where URLs appear as simple strings. The urlview command is a specialized utility designed to solve this problem: it scans text for URLs, extracts them using a powerful regular expression, and then displays an interactive menu (using a screen-oriented interface) from which you may select a URL. With your selection, a configured external command (often a web browser) is launched to view the URL.
Table of Contents
Here is a comprehensive guide to the options available with the urlview command −
- Understanding urlview Command
- Installation of urlview Command
- How to Use urlview Command in Linux?
- urlview Command Options
- Examples of urlview Command in Linux
Understanding urlview Command
Developed for environments where screen-based tools are the norm, urlview provides a convenient and efficient way to pick a URL from a cluttered text file. It's especially useful when reviewing emails, log files, or even when reading documentation where hyperlinks have been "printed" rather than linked directly.
Basic Concept and Use Case
Imagine you're reading the output of a mailing list archive, and a hundred URLs are scattered in the text. Instead of manually copying and pasting each link into your browser, you could pipe the file's contents to urlview, which then creates a numbered list of all URLs it can find.
The basic syntax is very straightforward −
urlview [filename ...]
If you provide one or more filenames, urlview scans these files; if you omit the filename, it reads from standard input. This flexibility makes it easy to integrate with other text processing utilities such as grep or even use it as part of a pipeline.
Installation of urlview Command
urlview is usually available in the package repositories of various Linux distributions. For example, on Debian-based systems you might install it with −
sudo apt-get install urlview

Likewise, on Fedora or Red Hat systems, you could use −
sudo yum install urlview
After installation, you can check its availability by querying the man page −
man urlview

Or simply running −
urlview --version
This step confirms that you have the utility installed and ready for use in your shell environment.
How to Use urlview Command in Linux?
Before urlview performs its extraction, it consults a configuration file for certain parameters. There are two primary files it checks −
- User-specific configuration: ~/.urlview
- System-wide configuration: /etc/urlview.conf
If the user-specific file doesn't exist, it falls back to the system-wide file. This design allows you to override site-wide defaults on a per-user basis.
Configuration Commands
Inside the configuration file, there are two main directives available −
REGEXP
This command defines the regular expression used to locate URLs in the input text. The default REGEXP is designed to match various URL formats and handle common characters while avoiding delimiters like quotes or angle brackets. An example entry looks like this −
REGEXP (((https?|ftp|gopher)://|(mailto|file|news):)[^' <>\"]+|(www|web|w3).[-a-z0-9.]+)[^' .,;<>\":]
You can alter this regular expression if you want to fine-tune URL matching. For example, if your text contains unconventional URL formats or if you want to exclude certain patterns, you can modify or replace the default expression.
The COMMAND Directive
This directive specifies the command that is executed when a URL is selected. The default command is typically −
COMMAND url_handler.sh %s
In this command, %s is a placeholder for the selected URL. If your configuration omits %s, then urlview will append the URL to the command string. You can alter this to launch any application you prefer or even chain multiple commands.
For instance, if you want to open the URL with Firefox, you might change the configuration to −
COMMAND firefox %s
Be cautious with quoting. The configuration is designed so that you should not need to put your own quotes around %s. urlview automatically handles shell quoting to ensure that URLs with spaces or special characters are managed safely.
urlview Command Options
While most of urlview's behavior is driven by its configuration file, there are a few command-line options available that control its operation −
Reading Files and Standard Input
Simply passing file names to urlview causes it to scan those files. Alternatively, if you want to use piped output from another command, you may run −
cat mylogfile.txt | urlview
Interactive Mode and Navigation
urlview is inherently interactive. When you run it, it creates a screen oriented menu (using curses or a similar library) where you can −
- Scroll through the list of extracted URLs.
- Use arrow keys or number keys to select a URL.
- Press Enter to execute the configured command for the selected URL.
There are no additional command-line switches to change this interactive behavior since it is the core purpose of the utility.
Version and Help Options
Like many Unix commands, urlview supports −
- --help − To display a usage message along with a summary of available options.
- --version − To print the current version of the command.
For instance −
urlview --help
This will output the basic usage syntax and a summary of its configuration, while
urlview --version
This will reveal version information and perhaps a copyright notice.
Examples of urlview Command in Linux
In this section, we have a set of examples that demonstrate some practical use cases of urlview command.
Viewing URLs in a Log File
Imagine you have a system log file (/var/log/app.log) that might contain several web addresses as part of error messages or debug information. To extract these URLs and choose one to open, simply run −
urlview /var/log/app.log
Piping Output from Other Utilities
Often you may want to extract URLs from the output of other commands. Suppose you want to extract all URLs printed by a command that lists email headers −
grep -o 'https\?://[^ ]*' email.txt | urlview
Here, grep extracts occurrences of URLs matching a simpler pattern, and the result feeds into urlview, which then presents them interactively. You can then choose any URL to open directly from the terminal.
Customizing the URL Extraction
If the default regular expression is not matching URLs the way you expect for instance, if your text includes unconventional URLs you can customize the configuration file. Create (or edit) a file named ~/.urlview with the following contents −
Custom REGEXP to match numerically prefixed URLs or nonstandard domains REGEXP (((https?|ftp)://)[^ '<>"]+|(www|web|w3)[.][-a-zA-Z0-9]+[.][a-zA-Z]{2,}) COMMAND firefox %s
Viewing URLs from a Pipe with Custom Output
Suppose you want to extract URLs from a text file generated by another command and then automatically open the selected URL without manual intervention. You could integrate urlview in a script. For example, a script might look like −
#!/bin/ Extract URLs from a file and open the selected URL using urlview selected_url=$(cat file_with_urls.txt | urlview) if [ -n "$selected_url" ]; then firefox "$selected_url" else echo "No URL was selected." fi
Conclusion
The urlview command is a powerful, yet elegantly simple Unix tool that fills a niche necessity: extracting and launching URLs from plain-text files easily and interactively.
Whether you're reading an email, inspecting a log file, or processing the output of a command-line tool, urlview dramatically reduces the friction of manually copying links into a browser.