Welcome 微信登录

首页 / 操作系统 / Linux / RHEL5.4下使用一条语句执行mkdir和cd命令

管理Linux系统的时候,我们如果新建一个文件夹一般情况下是下一步就是进去这个新建的文件,有没有想到过把新建文件夹和进入这个文件在一个命令里面执行呢,呵呵,本文就是介绍教你如何实现这个功能。下列操作在RHEL 5.4下面操作成功。。。传统方式我在这里就不介绍了,相信大家都知道,要实现新建目录和进入新建目录这个功能,需要修改一个文件,我是root用户目录下[root@localhost ~]# clear
[root@localhost ~]# pwd
/root
[root@localhost ~]# vi .bash_profile
# .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi# User specific environment and startup programsPATH=$PATH:$HOME/bin
function mkdircd () { mkdir -p "$@" && eval cd ""$$#""; }         // 这一行是添加的
export PATH
unset USERNAME
~
~
~
~
~
".bash_profile" 13L, 251C
保存修改的文件[root@localhost ~]# mkdircd /mnt/test                       //我们来执行下
-bash: mkdircd: command not found                           //呵呵,出错了
[root@localhost ~]# source .bash_profile                 //没关系,执行下,让它立即生效
[root@localhost ~]# mkdircd /mnt/test                      //再来一次
[root@localhost test]# pwd                            //OK,看到效果了,呵呵,还不去试试
/mnt/test Linux系统下如何快速在最近的2个目录之间来回切换Linux下C语言之调用简单函数相关资讯      Linux基础教程 
  • Linux基础教程:对文件打包压缩  (03月08日)
  • 基础教程:Linux 新手应该知道的   (09/06/2015 21:17:20)
  • Linux基础教程:find 与 xargs  (04/05/2015 10:20:11)
  • Linux基础教程:tar 命令使用介绍  (12/03/2015 13:19:47)
  • Linux基础教程(1)操作系统基础   (08/15/2015 20:44:01)
  • Linux基础教程:从源码安装软件  (04/05/2015 10:14:45)
本文评论 查看全部评论 (0)
表情: 姓名: 字数