zoukankan      html  css  js  c++  java
  • Linux命令:cd

    语法

    cd [-L|[-P [-e]]] [dir]
    改变shell当前工作目录。仅对执行命令所在的shell有效。

    参数

    -L  按符号链接进入目录。

    -P   按物理链接进入目录

    -e    如果指定-P,且路径不存在,则返回-e后指定的退出码。

    说明

     cd =change directory

    进入主目录。不带参数dir,就默认进入当前用户的主目录。等价命令还有 cd ~ 或 cd $HOME。

    进入上一次切换前的工作目录。cd - 或 cd $OLDPWD。如果反复执行,则会在最后两次工作目录间来回切换。

     cd的默认行为,等于cd <=> cd -L。如果路径中包含符号连接,则跟着符号链接走。

     CDPATH环境变量

    CDPATH环境变量为cd 提供一组备选的当前目录。也就是说,如果你输入的不是/开头的绝对路径,则进入的目录的绝对路径是CDPATH中的目录+你的目录。举例来说,

    架设你当前目录是/usr,myhome在你的/home下。

    export CDPATH=/root:/home/:/etc

    cd myhome

    执行以上命令后,bash会依次将CDPATH中的目录+myhome来进入,最终进入到/home/myhome目录下。【CDPATH中多个路径下都有dir怎么办?】

    进入你刚创建的目录

    mkdir <dir> && cd $_

    不论你创建的目录是否你当前工作目录下的,这个命令都能用。

    创建只有一个下划线名字的目录

    mkdir ./_

    help cd

     1 cd: cd [-L|[-P [-e]]] [dir]
     2     Change the shell working directory.
     3 
     4     Change the current directory to DIR.  The default DIR is the value of the
     5     HOME shell variable.
     6 
     7     The variable CDPATH defines the search path for the directory containing
     8     DIR.  Alternative directory names in CDPATH are separated by a colon (:).
     9     A null directory name is the same as the current directory.  If DIR begins
    10     with a slash (/), then CDPATH is not used.
    11 
    12     If the directory is not found, and the shell option `cdable_vars' is set,
    13     the word is assumed to be  a variable name.  If that variable has a value,
    14     its value is used for DIR.
    15 
    16     Options:
    17         -L      force symbolic links to be followed
    18         -P      use the physical directory structure without following symbolic
    19         links
    20         -e      if the -P option is supplied, and the current working directory
    21         cannot be determined successfully, exit with a non-zero status
    22 
    23     The default is to follow symbolic links, as if `-L' were specified.
    24 
    25     Exit Status:
    26     Returns 0 if the directory is changed, and if $PWD is set successfully when
    27     -P is used; non-zero otherwise.
    本篇文章出自“国民时代”,转载请注明转载出处。
  • 相关阅读:
    WIDER Face 转为 COCO 格式标签
    latex转word
    No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'
    COCO数据集使用super categories时出现IndexError: list index out of range
    VS Code 中 torch has no xxx member
    Anaconda中安装Cascade RCNN(Detectron)的若干问题
    fatal error: nvcuvid.h: No such file
    hive一些语句
    端口号
    hadoop错误: 找不到或无法加载主类 org.apache.hadoop.mapreduce.v2.app.MRAppMaster
  • 原文地址:https://www.cnblogs.com/ChinaGo/p/10634886.html
Copyright © 2011-2022 走看看