[问题]几个shell问题

sh/bash/dash/ksh/zsh等Shell脚本
回复
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

[问题]几个shell问题

#1

帖子 LinuxPing » 2006-04-09 15:36

看以下脚本:
1 # enable color support of ls and also add handy aliases
2 if [ "$TERM" != "dumb" ]; then
3 eval "`dircolors -b`"
4 alias ls='ls --color=auto'
5 #alias dir='ls --color=auto --format=vertical'
6 #alias vdir='ls --color=auto --format=long'
7 fi
8
9 # some more ls aliases
10 #alias ll='ls -l'
11 #alias la='ls -A'
12 #alias l='ls -CF'
13
14 # enable programmable completion features (you don't need to enable
15 # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
16 # sources /etc/bash.bashrc).
17 #if [ -f /etc/bash_completion ]; then
18 # . /etc/bash_completion
19 #fi
20
问题:
3 eval "`dircolors -b`" evall 是什么意思?
17 #if [ -f /etc/bash_completion ]; -f 前为何没有命令?
18 # . /etc/bash_completion 小数点是是什么意思?
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#2

帖子 LinuxPing » 2006-04-09 15:40

18 # . /etc/bash_completion 注意:小数点后有一空格,,并非表示当前目录下的文件~

谢~~~
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#3

帖子 LinuxPing » 2006-04-09 15:43

还有:
case "$TERM" in
xterm-color)
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
;;
*)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
;;
esac

问题:
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' ${debian_chroot:+($debian_chroot)}怎么理解? \u@\h:\w\$又是什么意思?
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#4

帖子 LinuxPing » 2006-04-09 15:47

还有:
trap ":" INT QUIT TSTP

#
# Call all parts in order.
#
steps=$(echo /etc/rcS.d/S??*)
num_steps=0
for step in $steps; do
num_steps=$(($num_steps + 1))
done
问题:trap 什么用? 后面参数是什么意思?
steps=$(echo /etc/rcS.d/S??*) 好像一般都用:steps=${echo /etc/rcS.d/S??*} 这里为什么我改
“{。。。}”为“(。。。)”
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#5

帖子 LinuxPing » 2006-04-09 15:49

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

怎么理解?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

#6

帖子 eexpress » 2006-04-09 19:07

找本liunx bash的看看。
● 鸣学
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#7

帖子 LinuxPing » 2006-04-10 2:09

哪位介绍本shell的书萨~~
~最好中文的,写出下载地址;如果你只写书名的话,你还是什么都不些出来的好~
~英文很难啃~~半天看不完一页~~那不是学linux,是学英语~
先谢~l
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

#8

帖子 leal » 2006-04-10 10:45

www.linuxcommand.org 这个站点很不错,虽然是英文的,简单

至于shell的书,可以先上书店看看,看到合自己的胃口/老外出的 一般都可以买,不过一本足矣
用心×恒 | 豆瓣 | 门户 | Blog
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

#9

帖子 leal » 2006-04-10 10:46

LinuxPing 写了:18 # . /etc/bash_completion 注意:小数点后有一空格,,并非表示当前目录下的文件~

谢~~~
和 source /etc/bash_completion 效果同,即执行这个脚本
用心×恒 | 豆瓣 | 门户 | Blog
daminggege
帖子: 7
注册时间: 2006-04-08 13:35

#10

帖子 daminggege » 2006-04-21 14:47

3.eval是对内容的二次扫描,这个我描述可能不是很清楚,简单按我理解就是如果一个命令你想在字符串中执行,可以用反引号,如果想要这种命令执行拼出的字符串再执行就用eval了
17. 判断是不是存在这个文件而已
18 # . /etc/bash_completion 注意:小数点后有一空格,,并非表示当前目录下的文件~
可以导入自定义的函数。

不好意思啊,有错误指正。仅仅想赚点分混混而已
回复