全部博文(136)
分类: LINUX
2008-12-14 12:48:43
[root@localhost yuechaotian]# pwd /home/yuechaotian [root@localhost yuechaotian]# ll 总用量 52 -r-------- 1 root root 22 9月 4 16:31 adsl帐号.txt -rw-rw-r-- 1 yuechaotian yuechaotian 2 12月 14 10:54 r.log -rw-rw-r-- 1 yuechaotian yuechaotian 0 12月 14 10:20 r.log.r -rw-rw-r-- 1 yuechaotian yuechaotian 24 12月 14 10:20 r.log.w drwx--x--x 3 root root 4096 12月 7 14:52 study drwxrwxrwx 2 yuechaotian yuechaotian 4096 12月 14 10:58 test -rw------- 1 root root 5789 12月 12 20:53 tnsnames.ora -r-------- 1 root root 22528 8月 31 10:26 房屋租赁合同.doc [root@localhost yuechaotian]# ll test/ 总用量 0 |
# > 将输出结果以"覆盖"的形式存储在指定的文件中, 若文件不存在则自动创建. [root@localhost yuechaotian]# ll > test/ll.log [root@localhost yuechaotian]# cat test/ll.log 总用量 52 -r-------- 1 root root 22 9月 4 16:31 adsl帐号.txt -rw-rw-r-- 1 yuechaotian yuechaotian 2 12月 14 10:54 r.log -rw-rw-r-- 1 yuechaotian yuechaotian 0 12月 14 10:20 r.log.r -rw-rw-r-- 1 yuechaotian yuechaotian 24 12月 14 10:20 r.log.w drwx--x--x 3 root root 4096 12月 7 14:52 study drwxrwxrwx 2 yuechaotian yuechaotian 4096 12月 14 11:01 test -rw------- 1 root root 5789 12月 12 20:53 tnsnames.ora -r-------- 1 root root 22528 8月 31 10:26 房屋租赁合同.doc # >> 将输出结果以“追加”的形式存储在指定的文件中, 若文件不存在则自动创建。 [root@localhost yuechaotian]# ll test/ >> test/ll.log [root@localhost yuechaotian]# cat test/ll.log 总用量 52 -r-------- 1 root root 22 9月 4 16:31 adsl帐号.txt -rw-rw-r-- 1 yuechaotian yuechaotian 2 12月 14 10:54 r.log -rw-rw-r-- 1 yuechaotian yuechaotian 0 12月 14 10:20 r.log.r -rw-rw-r-- 1 yuechaotian yuechaotian 24 12月 14 10:20 r.log.w drwx--x--x 3 root root 4096 12月 7 14:52 study drwxrwxrwx 2 yuechaotian yuechaotian 4096 12月 14 11:01 test -rw------- 1 root root 5789 12月 12 20:53 tnsnames.ora -r-------- 1 root root 22528 8月 31 10:26 房屋租赁合同.doc 总用量 4 -rw-r--r-- 1 root root 569 12月 14 11:01 ll.log |
[root@localhost yuechaotian]# ll testx > test/ll.log.2 ls: testx: 没有那个文件或目录 [root@localhost yuechaotian]# ll test/ 总用量 4 -rw-r--r-- 1 root root 631 12月 14 11:03 ll.log -rw-r--r-- 1 root root 0 12月 14 11:08 ll.log.2 [root@localhost yuechaotian]# cat test/ll.log.2 [root@localhost yuechaotian]# |
[root@localhost yuechaotian]# ll testx/ 1> test/ll.right 2> test/ll.wrong [root@localhost yuechaotian]# ll test/ 总用量 8 -rw-r--r-- 1 root root 631 12月 14 11:03 ll.log -rw-r--r-- 1 root root 0 12月 14 11:08 ll.log.2 -rw-r--r-- 1 root root 0 12月 14 11:11 ll.right -rw-r--r-- 1 root root 40 12月 14 11:11 ll.wrong [root@localhost yuechaotian]# cat test/ll.right [root@localhost yuechaotian]# cat test/ll.wrong ls: testx/: 没有那个文件或目录 |
[root@localhost yuechaotian]# ll test/ 总用量 8 -rw-r--r-- 1 root root 631 12月 14 11:03 ll.log -rw-r--r-- 1 root root 0 12月 14 11:08 ll.log.2 -rw-r--r-- 1 root root 0 12月 14 11:11 ll.right -rw-r--r-- 1 root root 40 12月 14 11:11 ll.wrong [root@localhost yuechaotian]# echo $? 0 [root@localhost yuechaotian]# ll testx/ ls: testx/: 没有那个文件或目录 [root@localhost yuechaotian]# echo $? 1 |
[root@localhost yuechaotian]# ll testx/ 1> test/ll.all 2>&1 [root@localhost yuechaotian]# cat test/ll.all ls: testx/: 没有那个文件或目录 |
[root@localhost yuechaotian]#ll testx/ 1> test/ll.right.only 2>/dev/null |
[root@localhost test]# cat ll.wrong ls: testx/: 没有那个文件或目录 [root@localhost test]# cat ll.right [root@localhost test]# cd subtest 1>> ll.right 2>> ll.wrong [root@localhost test]# cat ll.right [root@localhost test]# cat ll.wrong ls: testx/: 没有那个文件或目录 -bash: cd: subtest: 没有那个文件或目录 [root@localhost test]# ll ../ 1>> ll.right 2>> ll.wrong [root@localhost test]# cat ll.right 总用量 60 -r-------- 1 root root 22 9月 4 16:31 adsl帐号.txt -rw-r--r-- 1 root root 62 12月 14 11:02 ll.log -rw-rw-r-- 1 yuechaotian yuechaotian 2 12月 14 10:54 r.log -rw-rw-r-- 1 yuechaotian yuechaotian 0 12月 14 10:20 r.log.r -rw-rw-r-- 1 yuechaotian yuechaotian 24 12月 14 10:20 r.log.w -rw-r--r-- 1 root root 6 12月 14 11:06 s.log drwx--x--x 3 root root 4096 12月 7 14:52 study drwxrwxrwx 2 yuechaotian yuechaotian 4096 12月 14 11:20 test -rw------- 1 root root 5789 12月 12 20:53 tnsnames.ora -r-------- 1 root root 22528 8月 31 10:26 房屋租赁合同.doc [root@localhost test]# cat ll.wrong ls: testx/: 没有那个文件或目录 -bash: cd: subtest: 没有那个文件或目录 |
[root@localhost test]# rm * [root@localhost test]# echo "right and wrong" 1>> ll.r 2>>&1 -bash: syntax error near unexpected token `&' [root@localhost test]# ll 总用量 0 |
[root@localhost test]# echo "right and wrong" 1>> ll.r 2>&1 [root@localhost test]# ll 总用量 4 -rw-r--r-- 1 root root 16 12月 14 11:39 ll.r [root@localhost test]# cat ll.r right and wrong [root@localhost test]# echo "right and wrong2" 1>> ll.r 2>&1 [root@localhost test]# cat ll.r right and wrong right and wrong2 [root@localhost test]# ll "right and wrong2" 1>> ll.r 2>&1 [root@localhost test]# cat ll.r right and wrong right and wrong2 ls: right and wrong2: 没有那个文件或目录 |
[root@localhost test]# pwd /home/yuechaotian/test [root@localhost test]# rm * # 1. 输出正确则“追加”,输出错误则“覆盖” [root@localhost test]# echo "right_append & wrong_cover" 1>> ll.r 2> ll.w [root@localhost test]# cat ll.r right_append & wrong_cover [root@localhost test]# cat ll.w [root@localhost test]# echo "right_append & wrong_cover2" 1>> ll.r 2> ll.w [root@localhost test]# cat ll.r right_append & wrong_cover right_append & wrong_cover2 [root@localhost test]# cat ll.w [root@localhost test]# cd "right_append & wrong_cover2" 1>> ll.r 2> ll.w [root@localhost test]# cat ll.r right_append & wrong_cover right_append & wrong_cover2 [root@localhost test]# cat ll.w -bash: cd: right_append & wrong_cover2: 没有那个文件或目录 [root@localhost test]# cd "right_append & wrong_cover" 1>> ll.r 2> ll.w [root@localhost test]# cat ll.r right_append & wrong_cover right_append & wrong_cover2 [root@localhost test]# cat ll.w -bash: cd: right_append & wrong_cover: 没有那个文件或目录 #2. 输出正确则“覆盖”,输出错误则“追加” [root@localhost test]# echo "right_cover & wrong_append" 1> ll.r 2>> ll.w [root@localhost test]# cat ll.r right_cover & wrong_append [root@localhost test]# cat ll.w -bash: cd: right_append & wrong_cover: 没有那个文件或目录 [root@localhost test]# cd "right_cover & wrong_append" 1> ll.r 2>> ll.w [root@localhost test]# cat ll.r [root@localhost test]# cat ll.w -bash: cd: right_append & wrong_cover: 没有那个文件或目录 -bash: cd: right_cover & wrong_append: 没有那个文件或目录 |
# 1. 使用键盘输入方式来发送邮件给yuechaotian [root@localhost test]# mail -s "hi, yuechaotian" yuechaotian Hi, I'm root. . Cc: [root@localhost test]# su - yuechaotian [yuechaotian@localhost ~]$ [yuechaotian@localhost ~]$ procmail -v procmail v3.22 2001/09/10 Copyright (c) 1990-2001, Stephen R. van den Berg Copyright (c) 1997-2001, Philip A. Guenther Submit questions/answers to the procmail-related mailinglist by sending to: And of course, subscription and information requests for this list to: Locking strategies: dotlocking, fcntl() Default rcfile: $HOME/.procmailrc It may be writable by your primary group Your system mailbox: /var/mail/yuechaotian [yuechaotian@localhost ~]$ cat /var/mail/yuechaotian From root@localhost.localdomain Sun Dec 14 12:10:08 2008 Return-Path: Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.13.1/8.13.1) with ESMTP id mBE4A8U0001330 for by localhost.localdomain (8.13.1/8.13.1/Submit) id mBE4A86X001329 for yuechaotian; Sun, 14 Dec 2008 12:10:08 +0800 Date: Sun, 14 Dec 2008 12:10:08 +0800 From: root Message-Id: <200812140410.mBE4A86X001329@localhost.localdomain> To: yuechaotian@localhost.localdomain Subject: hi, yuechaotian Hi, I'm root. # 2. 那好,现在我将邮件内容保存到 mail.txt 中,使用 < 将 mail.txt 中的内容重新发送给yuechaotian [yuechaotian@localhost ~]$ su - root Password: [root@localhost ~]# cd /home/yuechaotian/ [root@localhost yuechaotian]# touch mail.txt [root@localhost yuechaotian]# echo > mail.txt "Hi, I'm root, I send this mail by using <." [root@localhost yuechaotian]# cat mail.txt Hi, I'm root, I send this mail by using <. [root@localhost yuechaotian]# mail -s "hi, yuechaotian" yuechaotian < mail.txt [root@localhost yuechaotian]# su - yuechaotian [yuechaotian@localhost ~]$ cat /var/mail/yuechaotian From root@localhost.localdomain Sun Dec 14 12:10:08 2008 Return-Path: Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.13.1/8.13.1) with ESMTP id mBE4A8U0001330 for by localhost.localdomain (8.13.1/8.13.1/Submit) id mBE4A86X001329 for yuechaotian; Sun, 14 Dec 2008 12:10:08 +0800 Date: Sun, 14 Dec 2008 12:10:08 +0800 From: root Message-Id: <200812140410.mBE4A86X001329@localhost.localdomain> To: yuechaotian@localhost.localdomain Subject: hi, yuechaotian Hi, I'm root. From root@localhost.localdomain Sun Dec 14 12:33:12 2008 Return-Path: Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by localhost.localdomain (8.13.1/8.13.1) with ESMTP id mBE4XCun024530 for by localhost.localdomain (8.13.1/8.13.1/Submit) id mBE4XChc024529 for yuechaotian; Sun, 14 Dec 2008 12:33:12 +0800 Date: Sun, 14 Dec 2008 12:33:12 +0800 From: root Message-Id: <200812140433.mBE4XChc024529@localhost.localdomain> To: yuechaotian@localhost.localdomain Subject: hi, yuechaotian Hi, I'm root, I send this mail by using <. [yuechaotian@localhost ~]$ |