Plan 9 from Bell Labs’s /usr/web/sources/contrib/maht/rc/grow_tree

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


#!/bin/rc

# 
# script for cloning a directory tree but no files 
# primary application : binding empty directories on /sys/src 
# Example :
# grow_tree /sys/src /tmp/tree 
# bind -ac /tmp/tree /sys/src

fn get_dirs {
	tmp = /tmp/$pid ^_dirs
	echo -n > $tmp

	for (f in `{du -nf $root_in | awk '{print $2}' }) 
		ls -l $f | grep '^d' | awk '{print $10}' >> $tmp
	dirs = `{sort $tmp}
	rm $tmp
}


root_in=$1
root_out=$2

if(~ $3 '') 
	get_dirs;
if not 
	dirs = `{cat $3};

mkdir $root_out

mkdir `{ echo $dirs | awk ' { gsub(ENVIRON["root_in"], ENVIRON["root_out"], $0); print } ' }

# bind -bc $root_out $root_in

# grow_tree /n/sauce/sys/src /usr/matt/kill0r /usr/matt/sys.src

# /n/sauce/sys/src/fs/killme

# /usr/matt/kill0r

# ls /n/sauce/sys/src/9/bitsy/*101

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to [email protected].