[问题]"()" and "{}"

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

[问题]"()" and "{}"

#1

帖子 LinuxPing » 2006-04-10 1:49

先在你的桌面建一个文本文件English ,随便输入点什么。。

在终端输入: debian_chroot=$(cat ~/Desktop/English)
没有错误提示~
在终端输入: debian_chroot=${cat ~/Desktop/English}
提示错误:bad substitution ---错误的替换。

()和 {} 区别是什么?
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#2

帖子 LinuxPing » 2006-04-10 1:55

第2个问题:
#shellScript:
[ -z "$PS1" ] && return
shopt -s checkwinsize
[ -x /usr/bin/lesspipe ] && eval "$(lesspipe)"


问题:shopt 什么东西?eval 什么东西?
$(lesspipe) 为什么用(),而不是${lesspipe}?
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

#3

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

$(command) 返回command执行后的结果

${VAR} 等同于 $VAR ,取出变量VAR的值
用心×恒 | 豆瓣 | 门户 | Blog
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#4

帖子 LinuxPing » 2006-04-11 9:55

谢~~
但还有问题你 没回答~~
头像
leal
帖子: 1119
注册时间: 2005-08-29 14:49
来自: 杭州
联系:

#5

帖子 leal » 2006-04-11 10:23

善用man
用心×恒 | 豆瓣 | 门户 | Blog
LinuxPing
帖子: 47
注册时间: 2006-03-21 16:21

#6

帖子 LinuxPing » 2006-04-11 14:47

man shopt --------- man eval什么都没有!!!(找不到帮助目录~)
windforest
帖子: 53
注册时间: 2005-12-13 20:56
联系:

#7

帖子 windforest » 2006-04-12 11:22

shopt, eval都是bash内嵌命令
看它们的帮助用help
如help shopt
头像
zhan
帖子: 1880
注册时间: 2005-08-15 0:04
来自: 南7技校

#8

帖子 zhan » 2006-05-30 19:04

所谓的用man的意思就是
man bash
飞得高,飞得低,学习再学习,多少大秘密!
http://zhan.blog.ubuntu.org.cn
zbspeed
帖子: 10
注册时间: 2006-10-04 22:20
来自: Chengdu Sichuan

#9

帖子 zbspeed » 2006-10-08 15:13

Syntax
======

eval arg [arg ...]

Description
===========

eval takes one or more arguments, which together comprise a Tcl script
containing one or more commands. eval concatenates all its arguments in the
same fashion as the concat command, passes the concatenated string to the
Tcl interpreter recursively, and returns the result of that evaluation (or
any error generated by it).
头像
bones7456
帖子: 8495
注册时间: 2006-04-12 20:05
来自: 杭州
联系:

#10

帖子 bones7456 » 2006-10-09 18:32

那$(command)和`command`有什么区别?
echo_mu
帖子: 21
注册时间: 2006-06-03 13:55

据我所知没啥大的区别

#11

帖子 echo_mu » 2006-10-13 12:42

$()这种格式更新一些,更容易嵌套使用。
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京

#12

帖子 aBiNg » 2006-10-13 19:44

$'command'
>command

单引号的作用是只做字面输出,不作shell解释...
echo_mu
帖子: 21
注册时间: 2006-06-03 13:55

#13

帖子 echo_mu » 2006-10-15 16:54

don-quixote 写了:$'command'
>command

单引号的作用是只做字面输出,不作shell解释...
那不是单引号,是esc下面那个键
aBiNg
帖子: 1331
注册时间: 2006-07-09 12:22
来自: 南京

#14

帖子 aBiNg » 2006-10-15 21:03

echo_mu 写了:
don-quixote 写了:$'command'
>command

单引号的作用是只做字面输出,不作shell解释...
那不是单引号,是esc下面那个键
不好意思~ :wink:
回复