ディレクトリツリー表示
wikiのリストタグでディレクトリツリーを表したい時などに。
ソース
#!/usr/bin/perl
use File::Find;
$key = '-';
$d = shift or $d = '.';
$d =~ s/^(.*)\/$/$1/;
find(\&show,($d));;
sub show {
$tmp = substr($File::Find::name,length $d);
return if $tmp eq '';
@names = split '/', $tmp;
shift @names;
$depth = (scalar @names);
print $key x $depth;
if (-d $_){
print "$_/\n";
}else{
print "$_\n";
}
}
使い方
> tree.pl /etc/X11/ -Xsession.options -rgb.txt -Xsession -Xresources/ --xfree86-common -app-defaults/ -Xsession.d/ --30xfree86-common_xresources --50xfree86-common_determine-startup --90xfree86-common_ssh-agent --99xfree86-common_start --20xfree86-common_process-args -cursors/ --handhelds.theme --redglass.theme --whiteglass.theme --core.theme -rstart/ --config --commands/ ---ListContexts ---ListGenericCommands ---@List ---x11r6/ ----LoadMonitor ----Terminal ----@List --contexts/ ---default ---x11r6 ---@List