cat: 顯示檔案內容


cat 是顯示檔案內容的指令, 通常我們都用它來顯示某個文字檔到標準輸出上. 例如我們想看 /usr/bin/clear 的內容:
[cherry:/home1/student/stud82/s8227] cat /usr/bin/clear
#!/usr/bin/sh
#       Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
#         All Rights Reserved
 
#       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#       The copyright notice above does not evidence any
#       actual or intended publication of such source code.
 
#ident  "@(#)clear.sh   1.7     93/04/07 SMI"   /* SVr4.0 1.3   */
#       Copyright (c) 1987, 1988 Microsoft Corporation
#         All Rights Reserved
 
#       This Module contains Proprietary Information of Microsoft
#       Corporation and should be treated as Confidential.
 
# clear the screen with terminfo.
# if an argument is given, print the clear string for that tty type
 
tput ${1:+-T$1} clear 2> /dev/null 
exit 
[cherry:/home1/student/stud82/s8227] 
或者是:
[cherry:/home1/student/stud82/s8227] cd /usr/bin
[cherry:/usr/bin] cat clear
#!/usr/bin/sh
#       Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T
#         All Rights Reserved
 
#       THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
#       The copyright notice above does not evidence any
#       actual or intended publication of such source code.
 
#ident  "@(#)clear.sh   1.7     93/04/07 SMI"   /* SVr4.0 1.3   */
#       Copyright (c) 1987, 1988 Microsoft Corporation
#         All Rights Reserved
 
#       This Module contains Proprietary Information of Microsoft
#       Corporation and should be treated as Confidential.
 
# clear the screen with terminfo.
# if an argument is given, print the clear string for that tty type
 
tput ${1:+-T$1} clear 2> /dev/null 
exit 
[cherry:/usr/bin]
這樣就把 /usr/bin/clear 這個檔案顯示出來了.
Source Code: cat