Plan 9 from Bell Labs’s /usr/web/sources/contrib/arisawa/misc/head

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


#!/bin/rc
rfork e
n=10
if(~ $1 -[0-9]*){
	n=`{echo $1|sed 's/-(.*)/\1/'}
	shift
}
if(~ $1 -*){
	echo 'usage: head [-n] file ...'
	exit usage
}

if(~ $#1 0){
	sed $n^q
	exit
}
p=':
'
if(~ $n 1)
	p=': '
f=$#*
while(~ $1 ?*){
	if(! ~ $f 1) echo -n $1$p
	sed $n^q $1
	shift
}


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.