shell脚本问题

sh/bash/dash/ksh/zsh等Shell脚本
回复
founderznd
帖子: 129
注册时间: 2009-08-16 17:34

shell脚本问题

#1

帖子 founderznd » 2009-09-29 17:18

代码: 全选

#!/bin/bash
cd /home/foundznd/桌面/
脚本这样写有什么问题么?
为何不能生效
如何才是正确的?
头像
tenzu
论坛版主
帖子: 36924
注册时间: 2008-11-21 20:26

Re: shell脚本问题

#2

帖子 tenzu » 2009-09-29 17:21

看着没错
会不会是因为“桌面”?
founderznd
帖子: 129
注册时间: 2009-08-16 17:34

Re: shell脚本问题

#3

帖子 founderznd » 2009-09-29 17:27

小弟也这么想,会不会是VI不支持中文的原因
但是换成是GEDIT依然不行,系统并没有报错。而且如果这样写

代码: 全选

#!/bin/bash
cd ~/桌面/
mkdir kkk
那么桌面就会创建一个kkk目录,这就说明第一句是生效了的。
但是为何我所在目录依然是原目录呢?
头像
xiooli
帖子: 6956
注册时间: 2007-11-19 21:51
来自: 成都
联系:

Re: shell脚本问题

#4

帖子 xiooli » 2009-09-29 17:53

在子shell里面运行了,不会影响父shell的。
founderznd
帖子: 129
注册时间: 2009-08-16 17:34

Re: shell脚本问题

#5

帖子 founderznd » 2009-09-29 17:56

明白了
那么就是说只能用别名的方式实现快速进入指定目录的功能了?
脚本不行吗?
头像
lululau
帖子: 105
注册时间: 2007-05-28 11:17

Re: shell脚本问题

#6

帖子 lululau » 2009-09-29 18:01

不喜欢中文路径
就在~/.config/user-dirs.dirs改成英文好了
founderznd
帖子: 129
注册时间: 2009-08-16 17:34

Re: shell脚本问题

#7

帖子 founderznd » 2009-09-29 18:13

lululau 写了:不喜欢中文路径
就在~/.config/user-dirs.dirs改成英文好了
谢谢~~
又知道一种方法了~ :em11
founderznd
帖子: 129
注册时间: 2009-08-16 17:34

Re: shell脚本问题

#8

帖子 founderznd » 2009-09-29 18:41

不过还是有个问题
就是左上角位置下拉菜单当中的桌面就失效了
怎么改呢?
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: shell脚本问题

#9

帖子 eexpress » 2009-09-29 22:04

你可以source 脚本的。
● 鸣学
aerofox
帖子: 1453
注册时间: 2008-05-24 8:30

Re: shell脚本问题

#10

帖子 aerofox » 2009-09-29 23:06

founderznd 写了:不过还是有个问题
就是左上角位置下拉菜单当中的桌面就失效了
怎么改呢?
再编辑菜单改过来。

据说 8.10 以后的版本可以在文件管理器中直接将“桌面”改为“Desktop”,系统就自动帮你其它的事做好了。我只用过 8.04 以前的版本,没试过。
founderznd 写了:那么就是说只能用别名的方式实现快速进入指定目录的功能了?
脚本不行吗?
简单的用别名,复杂的用函数。
回复