文件测试操作符 (五)

2014-11-24 11:22:28 · 作者: · 浏览: 18
t 1269432 2010-04-22 13:04 busybox
-rwxr-xr-x 1 root root 30200 2010-02-08 02:54 bzcat
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzcmp -> bzdiff
-rwxr-xr-x 1 root root 2140 2010-02-08 02:54 bzdiff
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzegrep -> bzgrep
-rwxr-xr-x 1 root root 4874 2010-02-08 02:54 bzexe
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzfgrep -> bzgrep
-rwxr-xr-x 1 root root 3642 2010-02-08 02:54 bzgrep
-rwxr-xr-x 1 root root 30200 2010-02-08 02:54 bzip2
-rwxr-xr-x 1 root root 9580 2010-02-08 02:54 bzip2recover
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzless -> bzmore
-rwxr-xr-x 1 root root 1297 2010-02-08 02:54 bzmore
-rwxr-xr-x 1 root root 50820 2010-03-04 19:29 cat
-rwxr-xr-x 1 root root 54956 2010-03-04 19:29 chgrp
-rwxr-xr-x 1 root root 50836 2010-03-04 19:29 chmod
-rwxr-xr-x 1 root root 54964 2010-03-04 19:29 chown
-rwxr-xr-x 1 root root 9632 2010-03-11 23:05 chvt
-rwxr-xr-x 1 root root 96140 2010-03-04 19:29 cp
-rwxr-xr-x 1 root root 114448 2010-03-04 19:25 cpio
-rwxr-xr-x 1 root root 83888 2010-04-01 12:22 dash
-rwxr-xr-x 1 root root 63128 2010-03-04 19:29 date
-rwxr-xr-x 1 root root 9672 2010-03-30 08:07 dbus-cleanup-sockets
-rwxr-xr-x 1 root root 292728 2010-03-30 08:07 dbus-daemon
-rwxr-xr-x 1 root root 5524 2010-03-30 08:07 dbus-uuidgen
-rwxr-xr-x 1 root root 54996 2010-03-04 19:29 dd
-rwxr-xr-x 1 root root 67316 2010-03-04 19:29 df
-rwxr-xr-x 1 root root 104528 2010-03-04 19:29 dir
-rwxr-xr-x 1 root root 5524 2010-03-22 10:51 dmesg
-rwxr-xr-x 1 root root 13824 2010-03-10 11:12 dnsdomainname
root@ubuntu:~/resource/shell-study/0506-2013#

root@ubuntu:~/resource/shell-study/0506-2013# ls
file.txt file.zip test1.sh test2.sh
root@ubuntu:~/resource/shell-study/0506-2013# ./test2.sh

Usage: test2.sh no filename!
root@ubuntu:~/resource/shell-study/0506-2013# ./test2.sh file
File file not found!
root@ubuntu:~/resource/shell-study/0506-2013# ./test2.sh file.zip
File file.zip is not a txt file!
root@ubuntu:~/resource/shell-study/0506-2013# ./test2.sh file.txt
total 7476
-rwxr-xr-x 1 root root 818232 2010-04-18 18:51 bash
-rwxr-xr-x 1 root root 30200 2010-02-08 02:54 bunzip2
-rwxr-xr-x 1 root root 1269432 2010-04-22 13:04 busybox
-rwxr-xr-x 1 root root 30200 2010-02-08 02:54 bzcat
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzcmp -> bzdiff
-rwxr-xr-x 1 root root 2140 2010-02-08 02:54 bzdiff
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzegrep -> bzgrep
-rwxr-xr-x 1 root root 4874 2010-02-08 02:54 bzexe
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzfgrep -> bzgrep
-rwxr-xr-x 1 root root 3642 2010-02-08 02:54 bzgrep
-rwxr-xr-x 1 root root 30200 2010-02-08 02:54 bzip2
-rwxr-xr-x 1 root root 9580 2010-02-08 02:54 bzip2recover
lrwxrwxrwx 1 root root 6 2012-11-30 05:12 bzless -> bzmore
-rwxr-xr-x 1 root root 1297 2010-02-08 02:54 bzmore
-rwxr-xr-x 1 root root 50820 2010-03-04 19:29 cat
-rwxr-xr-x 1 root root 54956 2010-03-04 19:29 chgrp
-rwxr-xr-x 1 root root 50836 2010-03-04 19:29 chmod
-rwxr-xr-x 1 root root 54964 2010-03-04 19:29 chown
-rwxr-xr-x 1 root root 9632 2010-03-11 23:05 chvt
-rwxr-xr-x 1 root root 96140 2010-03-04 19:29 cp
-rwxr-xr-x 1 root root 114448 2010-03-04 19:25 cpio
-rwxr-xr-x 1 root root 83888 2010-04-01 12:22 dash
-rwxr-xr-x 1 root root 63128 2010-03-04 19:29 date
-rwxr-xr-x 1 root root 9672 2010-03-30 08:07