Saturday, March 08, 2008
shell 编程之2>&1_一树寒梅白玉条,迥临村路傍溪桥
shell 编程之2>&1_一树寒梅白玉条,迥临村路傍溪桥: "下面通过一个例子来展示2>&1有什么作用:
$ cat test.sh
t
date
test.sh中包含两个命令,其中t是一个不存在的命令,执行会报错,默认情况下,错误会输出到stderr。date则能正确执行,并且输出时间信息,默认输出到stdout
./test.sh > test1.log
./test.sh: line 1: t: command not found
$ cat test1.log
Tue Oct 9 20:51:50 CST 2007
可以看到,date的执行结果被重定向到log文件中了,而t无法执行的错误则只打印在屏幕上。
$ ./test.sh > test2.log 2>&1
$ cat test2.log
./test.sh: line 1: t: command not found
Tue Oct 9 20:53:44 CST 2007
这次,stderr和stdout的内容都被重定向到log文件中了。"
$ cat test.sh
t
date
test.sh中包含两个命令,其中t是一个不存在的命令,执行会报错,默认情况下,错误会输出到stderr。date则能正确执行,并且输出时间信息,默认输出到stdout
./test.sh > test1.log
./test.sh: line 1: t: command not found
$ cat test1.log
Tue Oct 9 20:51:50 CST 2007
可以看到,date的执行结果被重定向到log文件中了,而t无法执行的错误则只打印在屏幕上。
$ ./test.sh > test2.log 2>&1
$ cat test2.log
./test.sh: line 1: t: command not found
Tue Oct 9 20:53:44 CST 2007
这次,stderr和stdout的内容都被重定向到log文件中了。"
关于>&2、2>&1等重定向的详细解释_Road to OU (Oracle&Unix)
关于>&2、2>&1等重定向的详细解释_Road to OU (Oracle&Unix)
* 2>&1 就是将 stderr 并进 stdout 作输出
* 1>&2 或 >&2 就是将 stdout 并进 stderr 作输出
* 2>&1 就是将 stderr 并进 stdout 作输出
* 1>&2 或 >&2 就是将 stdout 并进 stderr 作输出
Wednesday, March 05, 2008
2.4 Special Keys
2.4 Special Keys: "Chapter 2: Getting Started on a UNIX System
2.4 Special Keys
Like all systems, UNIX has a number"
2.4 Special Keys
Like all systems, UNIX has a number"
Name | Control Char | Function |
---|---|---|
erase | Erase character. Backspace and erase one character (the key used depends on terminal setting). Sometimes, especially within tcl/tk applications, you must use | |
werase | Delete the rightmost word typed in. | |
kill | Kill (erase) the line typed in so far.[8] | |
intr | Interrupt the program currently running. | |
rprnt | Reprint the line typed in so far. | |
flush | Stops terminal output until you press a key. | |
susp | Suspend the program currently running and put it in the background. This does not stop the process as it does in VMS! | |
stop | Stop the display. To resume, press the start key | |
start | Start the display after stop. | |
eof | Send the program an end-of-file character. |
Tuesday, March 04, 2008
Linux 一句话精彩问答基础知识 - Linux Unix As400
Linux 一句话精彩问答基础知识 - Linux Unix As400: "在有scsi硬盘的计算机上,如果用上面的命令挂载usb闪存,则会mount到/boot分区。这种情
况,应该先用fdisk -l /dev/sd? 来看看到底usb闪存盘是在哪个设备下(通常会是sdb或者sdc)。
比如某台机器上,就是在sdc1 上面。
所有/etc/fstab 内容 mount -a 指定文件格式'-t 格式', 格式可以为vfat, ext2, ext3 等.
访问DVD mount -t iso9660 /dev/dvd /mnt/cdrom 或mount -t udf /dev/dvd /mnt/cdrom
注意:dvd 的格式一般为iso9660 或udf 之一
1006 在vmware 的LINUX 中使用本地硬盘的FAT 分区
将本地的FAT 分区共享,然后在VMWARE 中使用SMBFS 挂上。可以将如下的行放到
/etc/fstab 中:"
况,应该先用fdisk -l /dev/sd? 来看看到底usb闪存盘是在哪个设备下(通常会是sdb或者sdc)。
比如某台机器上,就是在sdc1 上面。
所有/etc/fstab 内容 mount -a 指定文件格式'-t 格式', 格式可以为vfat, ext2, ext3 等.
访问DVD mount -t iso9660 /dev/dvd /mnt/cdrom 或mount -t udf /dev/dvd /mnt/cdrom
注意:dvd 的格式一般为iso9660 或udf 之一
1006 在vmware 的LINUX 中使用本地硬盘的FAT 分区
将本地的FAT 分区共享,然后在VMWARE 中使用SMBFS 挂上。可以将如下的行放到
/etc/fstab 中:"
我的.cshrc文件
我的.cshrc文件: "# $FreeBSD: src/etc/root/dot.cshrc,v 1.29 2004/04/01 19:28:00 krion Exp $
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
lias h history 25
alias j jobs -l
alias la ls -a
alias lf ls -FA
alias ll ls -lA
alias lls ls -G
# A righteous umask
umask 22
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin /usr/local/jdk1.4.2/bin /usr/local/jdk1.4.2/jre/bin $HOME/bin)
setenv EDITOR ee
setenv PAGER more
setenv BLOCKSIZE K
setenv LANG zh_CN.eucCN
setenv LC_ALL zh_CN.eucCN
setenv LC_CTYPE zh_CN.eucCN
setenv JAVA_HOME /usr/local/jdk1.4.2
setenv CLASSPATH .:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/jre
setenv XMODIFIERS @im=fcitx
if ($?prompt) then
# An interactive shell -- set some stuff up
set prompt = '%B%m@%n[%/]# '
set filec
set history = 100
set savehist = 100
set mail = (/var/mail/$USER)
if ( $?tcsh ) then
bindkey '^W' backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
endif
endif"
#
# .cshrc - csh resource script, read at beginning of execution by each shell
#
# see also csh(1), environ(7).
lias h history 25
alias j jobs -l
alias la ls -a
alias lf ls -FA
alias ll ls -lA
alias lls ls -G
# A righteous umask
umask 22
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/sbin /usr/local/bin /usr/X11R6/bin /usr/local/jdk1.4.2/bin /usr/local/jdk1.4.2/jre/bin $HOME/bin)
setenv EDITOR ee
setenv PAGER more
setenv BLOCKSIZE K
setenv LANG zh_CN.eucCN
setenv LC_ALL zh_CN.eucCN
setenv LC_CTYPE zh_CN.eucCN
setenv JAVA_HOME /usr/local/jdk1.4.2
setenv CLASSPATH .:$JAVA_HOME/lib:$JAVA_HOME/jre/lib:$JAVA_HOME/jre
setenv XMODIFIERS @im=fcitx
if ($?prompt) then
# An interactive shell -- set some stuff up
set prompt = '%B%m@%n[%/]# '
set filec
set history = 100
set savehist = 100
set mail = (/var/mail/$USER)
if ( $?tcsh ) then
bindkey '^W' backward-delete-word
bindkey -k up history-search-backward
bindkey -k down history-search-forward
endif
endif"
CSH Multiline prompt Linux on your way - Powered by Sablog-X
CSH Multiline prompt Linux on your way - Powered by Sablog-X: "# %B begin bold
# %b end bold
# %{ begin control escape
# %} end control escape, cannot be the last in prompt
# %m hostname, without domain
# %/ current directory
# %D day in dd format
# %W month in mm format
# %Y year in yyyy format
# %l tty
# %P time in 24 hour format
# %h history number"
# %b end bold
# %{ begin control escape
# %} end control escape, cannot be the last in prompt
# %m hostname, without domain
# %/ current directory
# %D day in dd format
# %W month in mm format
# %Y year in yyyy format
# %l tty
# %P time in 24 hour format
# %h history number"
Monday, March 03, 2008
关于Linux操作系统提示符PS1定义的问题-Linux伊甸园----Linux|Unix|新闻|下载|论坛|�
Subscribe to:
Posts (Atom)