LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 899|回复: 5

关于一个sehll script小脚本的问题

[复制链接]
发表于 2005-5-10 20:05:57 | 显示全部楼层 |阅读模式
[root@localhost kk]# cat 3  
#!/bin/bash
xx='Current directory is''pwd'
echo $xx
[root@localhost kk]# ./3
Current directory ispwd
[root@localhost kk]#
这又是为什么啊
怎么就当字符输出了
而不是输出路径啊

我也试着写过
xx='Current directory is' 'pwd'
echo $xx
但这样就输出pwd命令的结果  当前路径而不显示前面的文字了
发表于 2005-5-10 21:32:03 | 显示全部楼层
echo "current directory is $(pwd)"
回复 支持 反对

使用道具 举报

发表于 2005-5-10 22:59:17 | 显示全部楼层
echo  current directory is `pwd`


注意为键盘左上角的小分号
回复 支持 反对

使用道具 举报

发表于 2005-5-11 09:45:27 | 显示全部楼层
xx="Current directory is `pwd`"
回复 支持 反对

使用道具 举报

发表于 2005-5-11 12:42:57 | 显示全部楼层
echo current directory is $PWD
回复 支持 反对

使用道具 举报

发表于 2005-5-12 02:42:37 | 显示全部楼层
Post by ccic
[root@localhost kk]# cat 3  
#!/bin/bash
xx='Current directory is''pwd'
echo $xx
[root@localhost kk]# ./3
Current directory ispwd
[root@localhost kk]#
这又是为什么啊
怎么就当字符输出了
而不是输出路径啊

我也试着写过
xx='Current directory is' 'pwd'
echo $xx
但这样就输出pwd命令的结果  当前路径而不显示前面的文字了

晕~~~,看来这里论坛的资源全浪费啦~~
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表