ref: 147c0127fb766de457fe12d0b66f23cd17c028cc
dir: /path/
#!/bin/rc
# x/path -- extract datums from the path
rfork e
if(! ~ $$#* -*)
wd=$$#*
if not
wd=`{pwd}
for(arg){
switch($arg){
case -P
echo $wd | sed 's,/[^/]+/[^/]+(.*),\1,'
case -p
echo $wd | sed 's,/[^/]+/[^/]+/(.*),\1,'
case -r
echo $wd | sed 's,(/[^/]+/[^/]+).*,\1,'
case -l
echo $wd | awk -F/ '{print $3}'
}
shift
}