Commands tagged w3m (5)

  • Turns a PDF into HTML (without images) and prints it to the standard out which is picked up and interpreted by w3m.


    4
    pdftohtml -i -stdout FILE.pdf | w3m -T text/html
    Haegin · 2010-11-03 12:01:01 44
  • change the nfl in the url to mlb or nba to get those score/times as well Show Sample Output


    2
    w3m -no-cookie http://m.espn.go.com/nfl/scoreboard?|sed 's/ Final/ : Final/g'|sed 's/ F\// : F\//g'|sed 's/, / : /g'|grep -i ':'
    SQUIIDUX · 2010-11-15 01:18:19 17
  • Uses Google's "OneBox" to look up the sunrise in any city by name. If no city is specified, it defaults to Seattle. For the sunset time, you change the search query to "sunset", like so, . sunset() { city=${1-Seattle}; w3m "google.com/search?q=sunset:$city" | sed -r '1,/^\s*1\./d; /^\s*2\./,$d; /^$/d' ;} . "OneBox" is Google's term for that box that appears before the organic search results that has useful information that Google thinks you might be looking for (mathematical calculations, weather, currency conversions, and such). I'm not actually using OneBox correctly, but that's because I'm not sure that there is a "correctly". I looked for a command line API, but couldn't find one, so I settled on parsing stdout from the fantastic w3m web browser. I use the sed script to show only the first hit by deleting everything from the beginning of the file until it sees " 1." and then deleting everything from " 2." to the end of the file. Ugly and fragile, yes, but it works fine. . BUG1: w3m represents the picture of the sun rising, "weather_sunset-40.gif" as "[weat]" which is slightly confusing and probably should be removed. . BUG2: The output is more easily readable by a human, which means it's less useful for scripting. Show Sample Output


    0
    sunrise() { city=${1-Seattle}; w3m "google.com/search?q=sunrise:$city" | sed -r '1,/^\s*1\./d; /^\s*2\./,$d; /^$/d' ;}
    hackerb9 · 2010-11-02 21:24:23 3
  • Just feed classical duckduckgo request replacing the "!" for the bang by a "-" (ie. "ddg -gi mickey mouse") and the result will be opened in w3m (think of installing w3m-img for image support in xterm or tty) To put it in the .bashrc, remove the "\" that escapes the "!".


    0
    ddg(){ search=""; bang=""; for term in $@; do if [[ "$term" =~ -([A-Za-z0-9._%+-]*) ]]; then bang="\!${BASH_REMATCH[1]}" ; else search="$search%20$term" ; fi ; done ; w3m "https://www.duckduckgo.com/?q=$bang$search" ;}
    boustrophedon757 · 2013-10-30 21:41:36 6
  • You can put this at .bashrc or .profile and get a random tip every time you open a terminal Show Sample Output


    0
    w3m -dump http://www.commandlinefu.com/commands/random/plaintext
    noobcodr · 2017-05-14 02:11:12 21

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands


Check These Out

Solaris - check ports/sockets which process has opened

tar via network

Which processes are listening on a specific port (e.g. port 80)
swap out "80" for your port of interest. Can use port number or named ports e.g. "http"

Unite pdf files
pdfunite is a part of the poppler-utils. poppler-utils package is only 150KB. The alternative - pdftk package is 14MB! Install poppler-utils if you need simple pdf operation commands like unite, separate, info, text/html conversions

ls -qaltr # list directory in chronological order, most recent files at end of list
I find it very handy to be able to quickly see the most recently modified/created files in a directory. Note that the "q" option will reveal any files with non-printable characters in their filename.

Remove ( color / special / escape / ANSI ) codes, from text, with sed
Remove ( color / special / escape / ANSI ) codes, from text, with sed Credit to the original folks who I've copied this command from. The diff here is: Theirs: [m|K] Theirs is supposed to remove \E[NUMBERS;NUMBERS[m OR K] This statement is incorrect in 2 ways. 1. The letters m and K are two of more than 20+ possible letters that can end these sequences. 2. Inside []'s , OR is already assumed, so they are also looking for sequences ending with | which is not correct. This : [a-zA-Z] This resolves the "OR" issue noted above, and takes care of all sequences, as they all end with a lower or upper cased letter. This ensures 100% of any escape code 'mess' is removed.

Get names of files in /dev, a USB device is attached to
This command lists the names of your USB devices connected and what file in /dev they are using. It's pretty useful if you don't have an automount option in your desktop or you don't have any graphical enviroment.

Get your external IP address if your machine has a DNS entry
Easy way to see your real external IP

Replaces a color in a PDF document, useful for removing a dark background before printing.
The pdf is first converted to a bitmap, so change "-density" to match your printer resolution. Also be careful about the RAM required. In this example rgb(0,0,0) is replaced by rgb(255,255,255), change to suit your needs.

add all files not under version control to repository
With the force options the same results can be achieved


Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: