系统之家 - 系统光盘下载网站!

当前位置:系统之家 > 系统教程 > Linux bash命令操作技巧

Linux初学者需了解的Bash命令操作技巧分享

时间:2014-12-11 15:24:09 作者:qipeng 来源:系统之家 1. 扫描二维码随时看资讯 2. 请使用手机浏览器访问: https://m.xitongzhijia.net/xtjc/20141211/32382.html 手机查看 评论

  Bash是Bourne-Again SHell的缩写,是许多Linux平台内定的shell,其实Bash命令有许多操作技巧,很多初学者可能还不知道,掌握这些技巧能够更快的完成工作,一起来学习下吧。

 Linux初学者需了解的Bash命令操作技巧分享

  tab键补全用法

  当我们敲击一下tab补全命令或文件名

  当我们敲击两下tab 列出相关的所有可选项

  cd - 相当于电视的回看

  有时候我们进入一个非常长的目录,后来又进入另一个目录,可能我们还行回到原来那个长,如果事先知道,我们可能输入pwd ,以便一会儿粘贴,有时候忘了输入pwd我们可能无奈还得输入一次长长的路径,我们可以输入一下cd -试试,直接回到上次进入的目录,就像是看电视时候的回看按钮。是不是很好用?

  查看以下例子

  [root@localhost /]# cd /tmp

  [root@localhost tmp]# pwd

  /tmp

  [root@localhost tmp]# cd /

  [root@localhost /]# pwd

  /

  [root@localhost /]# cd -

  /tmp

  [root@localhost tmp]# pwd

  /tmp

  Esc+.

  用法举例

  首先touch一个文件,然后编辑这个文件

  touch abcdefghijk

  敲入vi ,然后Esc+. 发现是不是abcdefghijk已经出现在vi后面\

  转义字符用法

  系统中一些命令都是别名的功能,比如我们使用的rm、mv等,实际上是 rm -i和mv -i 。

  查看系统别名可以使用alias命令,例如以下系统默认的别名。

  [root@localhost testdir]# alias

  alias cp=‘cp -i’

  alias egrep=‘egrep --color=auto’

  alias fgrep=‘fgrep --color=auto’

  alias grep=‘grep --color=auto’

  alias l.=‘ls -d .* --color=auto’

  alias ll=‘ls -l --color=auto’

  alias ls=‘ls --color=auto’

  alias mv=‘mv -i’

  alias rm=‘rm -i’

  alias which=‘alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde’

  有时候我们删一个文件时候,会出现以下提示, 需要我们一个个确认,原因就是rm默认就是rm -i起了作用。

  [root@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

  [root@localhost dir1]# rm file1 file2 file3 file4rm: remove regular empty file ?.ile1?。 y

  rm: remove regular empty file ?.ile2?。 y

  rm: remove regular empty file ?.ile3?。 y

  rm: remove regular empty file ?.ile4?。 y

  我们可以使用转移字符使别名失效,使用如下,删除就不会再有提示确认了。

  [root@localhost testdir]# cd dir1

  [root@localhost dir1]# ls

  file1 file2 file3 file4

  [root@localhost dir1]# \rm file1 file2 file3 file4

  上面就是bash命令的操作技巧的介绍了,想要学的精,光掌握命令是不够的,还要灵活应用一些操作技巧,这样才能事半功倍,你学会了吗?

发表评论

0

没有更多评论了

评论就这些咯,让大家也知道你的独特见解

立即评论

以上留言仅代表用户个人观点,不代表系统之家立场

其他版本软件

热门教程

人气教程排行

Linux系统推荐

官方交流群 软件收录