博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
cd in bash
阅读量:6417 次
发布时间:2019-06-23

本文共 2737 字,大约阅读时间需要 9 分钟。

  hot3.png

cd: cd [-L] [-P [-e]] [dir]

    Change the current directory to DIR.The default DIR is the value of the HOME shell variable.

    The variable CDPATH defines the search path for the directory containing DIR.Alternative directory names in CDPATH are separated by a colon(:).A null directory name is the same as the current directory. If DIR begins with a slash(/), then CDPATH is not used.

    If the directory is not found,and the shell option `cdable_vars` is set,the word is assumed to be a variable name.If that variable has a value,its value is used for DIR.

   Options:

        -L    force symbolic links to be followed

        -P    use the physical directory structure without following symbolic links

        -e    if the -P option is supplied,and the current working directory cannot be determined successfully,exit with a non-zero status

   The default is to follow symbolic links,as if '-L' were specified.

    Exit Status:

    Return 0 if the directory is changed,and if $PWD is set successfully when -P is used;non-zero otherwise.

    Since cd is used to change the current directory to DIR,what is DIR?

    DIR is a pathname,which can be determined by command line argument [dir].

    If [dir] is empty,DIR is the value of the HOME shell variable.

huihoo@huihoo:/home/huihoo/lab$ HOME=/tmphuihoo@huihoo:/home/huihoo/lab$ echo $HOME/tmphuihoo@huihoo:/home/huihoo/lab$ cdhuihoo@huihoo:~$ pwd/tmphuihoo@huihoo:~$
    If [dir] is null,namely "", DIR is the same as the current directory.
huihoo@huihoo:~/lab$ pwd/home/huihoo/labhuihoo@huihoo:~/lab$ cd ""huihoo@huihoo:~/lab$ pwd/home/huihoo/labhuihoo@huihoo:~/lab$
    If [dir]  begins with a slash(/), then DIR is the same as [dir].
huihoo@huihoo:~/lab$ cd /tmphuihoo@huihoo:/tmp$ pwd/tmphuihoo@huihoo:/tmp$
    If [dir] is a relative pathname,then she SHELL variable CDPATH works.It defines the search path for the directory containing DIR.Alternative directory names in CDPATH are separated by a colon(:).

    If CDPATH is null,relative pathname is relative to current directory.

huihoo@huihoo:~$ echo $CDPATH/libhuihoo@huihoo:~$ ls /lib/firmware/b43 -d/lib/firmware/b43huihoo@huihoo:~$ cd firmware/b43/lib/firmware/b43huihoo@huihoo:/lib/firmware/b43$ pwd/lib/firmware/b43huihoo@huihoo:/lib/firmware/b43$

     If the [dir] directory is not found(including CDPATH and current directory),and the shell option 'cdable_vars' is set,[dir] is assumed to be a variable name,
huihoo@huihoo:/tmp$ CDPATH=/libhuihoo@huihoo:/tmp$ firmware=/tmphuihoo@huihoo:/tmp$ cd firmware/lib/firmwarehuihoo@huihoo:/lib/firmware$ doc=/tmphuihoo@huihoo:/lib/firmware$ ls /lib/docls: cannot access /lib/doc: No such file or directoryhuihoo@huihoo:/lib/firmware$ cd doc/tmphuihoo@huihoo:/tmp$ shopt cdable_varscdable_vars        on huihoo@huihoo:/tmp$

转载于:https://my.oschina.net/huihu/blog/190173

你可能感兴趣的文章
JavaMail邮箱验证用户注册
查看>>
系统时间——ntpd
查看>>
反射实现AOP动态代理模式(Spring AOP实现原理)
查看>>
Http协议与缓存
查看>>
监测超过特定内存阀值进程并结束
查看>>
Linux Centos 查询信息
查看>>
android adb命令
查看>>
python “双”稀疏矩阵转换为最小联通量“单”矩阵
查看>>
揭秘天猫双11背后:20万商家600万张海报,背后只有一个鹿班
查看>>
重置mysq root密码脚本
查看>>
我的友情链接
查看>>
MHA配置参数
查看>>
深入理解Lock
查看>>
vim的块选择
查看>>
HTML --块
查看>>
在DLL中获取主进程窗口句柄
查看>>
基于消息队列的双向通信
查看>>
一个不错的loading效果
查看>>
Debian允许root用户登录
查看>>
linux的文件系统
查看>>