Plan 9 from Bell Labs’s /usr/web/sources/contrib/steve/rc/google

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#!/bin/rc

rfork e
srch='/search?q='

fn usage {
	echo 'usage: google [-wgi] text...' >[1=2]
	echo '       text may be multiple words or/and quoted phrases'
	exit 'usage'
}

while(! ~ $#* 0 && ~ $1 -* && ! ~ $1 --){
	switch($1){
	case -m
		srch='/maps?q='
	case -w
		srch='/search?q='
	case -g
		srch='/groups?q='
	case -i
		srch='/images?q='
	case *
		usage
	}
	shift
}

if ( ~ $#* 0)
	usage

pat=''
for (p){
	if(echo $p | grep -s '[ 	]')
		p='%22'^`{echo $p | sed 's/[ 	]/+/g'}^'%22'
	pat=$pat+$p
}

plumb http://google.com^$srch^$pat


Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.