22Hz 2016. 6. 1. 03:13

[root@linux220 ~/bin]# pstree
init─┬─VGAuthService
     ├─acpid
     ├─atd
     ├─auditd─┬─audispd───{audispd}
     │        └─{auditd}
     ├─automount───4*[{automount}]
     ├─avahi-daemon───avahi-daemon
     ├─bonobo-activati───{bonobo-activati}
     ├─bt-applet
     ├─clock-applet
     ├─crond
     ├─cupsd
     ├─2*[dbus-daemon]
     ├─dbus-launch
     ├─dovecot─┬─dovecot-auth
     │         ├─3*[imap-login]
     │         └─3*[pop3-login]
     ├─eggcups
     ├─escd───{escd}
     ├─events/0
     ├─events/1
     ├─events/2
     ├─events/3
     ├─gam_server
     ├─gconfd-2
     ├─gdm-binary───gdm-binary─┬─Xorg
     │                         └─gnome-session───ssh-agent
     ├─gdm-rh-security───{gdm-rh-security}
     ├─gnome-keyring-d
     ├─gnome-panel
     ├─gnome-power-man
     ├─gnome-screensav
     ├─gnome-settings-───{gnome-settings-}
     ├─gnome-terminal─┬─bash
     │                ├─bash───pstree
     │                ├─gnome-pty-helpe
     │                └─{gnome-terminal}
     ├─gnome-vfs-daemo
     ├─gnome-volume-ma
     ├─gpm
     ├─hald───hald-runner─┬─hald-addon-acpi
     │                    ├─hald-addon-keyb
     │                    └─hald-addon-stor
     ├─hpiod
     ├─httpd───8*[httpd]
     ├─irqbalance
     ├─khelper
     ├─klogd
     ├─ksoftirqd/0
     ├─ksoftirqd/1
     ├─ksoftirqd/2
     ├─ksoftirqd/3
     ├─kthread─┬─aio/0
     │         ├─aio/1
     │         ├─aio/2
     │         ├─aio/3
     │         ├─ata/0
     │         ├─ata/1
     │         ├─ata/2
     │         ├─ata/3
     │         ├─ata_aux
     │         ├─cqueue/0
     │         ├─cqueue/1
     │         ├─cqueue/2
     │         ├─cqueue/3
     │         ├─kacpid
     │         ├─kauditd
     │         ├─kblockd/0
     │         ├─kblockd/1
     │         ├─kblockd/2
     │         ├─kblockd/3
     │         ├─kgameportd
     │         ├─khubd
     │         ├─khungtaskd
     │         ├─2*[kjournald]
     │         ├─kmpath_handlerd
     │         ├─kmpathd/0
     │         ├─kmpathd/1
     │         ├─kmpathd/2
     │         ├─kmpathd/3
     │         ├─kpsmoused
     │         ├─kseriod
     │         ├─ksnapd
     │         ├─kstriped
     │         ├─kswapd0
     │         ├─mpt/0
     │         ├─mpt_poll_0
     │         ├─2*[pdflush]
     │         ├─rpciod/0
     │         ├─rpciod/1
     │         ├─rpciod/2
     │         ├─rpciod/3
     │         ├─scsi_eh_0
     │         └─vmmemctl
     ├─mapping-daemon
     ├─metacity
     ├─migration/0
     ├─migration/1
     ├─migration/2
     ├─migration/3
     ├─6*[mingetty]
     ├─mixer_applet2───{mixer_applet2}
     ├─named───6*[{named}]
     ├─nautilus
     ├─nm-applet
     ├─nm-system-setti
     ├─notification-ar
     ├─pam-panel-icon───pam_timestamp_c
     ├─pcscd───3*[{pcscd}]
     ├─portmap
     ├─python
     ├─rpc.idmapd
     ├─rpc.statd
     ├─2*[sendmail]
     ├─smartd
     ├─sshd
     ├─syslogd
     ├─trashapplet
     ├─udevd
     ├─vmtoolsd───{vmtoolsd}
     ├─vmtoolsd
     ├─vsftpd
     ├─watchdog/0
     ├─watchdog/1
     ├─watchdog/2
     ├─watchdog/3
     ├─wnck-applet
     ├─xfs
     └─xinetd
[root@linux220 ~/bin]#

 


# dl.sh /test
/test─┬─dir1
       ├─dir2─┬─dir4
       │        ├─dir5
       │        └─dir6
       └─dir3

 


1. 디렉토리의 목록을 받아야 한다
# find /test -type d

[root@linux220 ~/bin]# rm -rf /test/*
[root@linux220 ~/bin]# cd /test
[root@linux220 /test]# ls
[root@linux220 /test]# mkdir -p dir1
[root@linux220 /test]# mkdir -p dir2/{dir4,dir5,dir6}
[root@linux220 /test]# mkdir -p dir3
[root@linux220 /test]# find /test -type d
/test
/test/dir3
/test/dir1
/test/dir2
/test/dir2/dir4
/test/dir2/dir5
/test/dir2/dir6


[root@linux220 /test]# tree
.
|-- dir1
|-- dir2
|   |-- dir4
|   |-- dir5
|   `-- dir6
`-- dir3

6 directories, 0 files


2. 출력되는 결과에서 형태를 변환
/test -> ├
/test/dir2 -> ├
dir4 -> ┬
dir5 -> │
dir6 -> └


3. 그림을 그려서 매치
/test
/test/dir3
/test/dir1
/test/dir2
/test/dir2/dir4
/test/dir2/dir5
/test/dir2/dir6

/test─┬─dir1
       ├─dir2─┬─dir4
       │        ├─dir5
       │        └─dir6
       └─dir3

 


4. expect() 함수, 명령어 사용