我是靠谱客的博主 含蓄大地,这篇文章主要介绍命令相关1.ls屏蔽波浪线~作为文件名结尾的文件 2.source命令  .点命令 4.bash常常需要在~/.bashrc文件的末尾加上 export PATH=/PATH/TO/SDK_OR_JDK:$PATH 类是这样的命令,然后在source一下这个~/.bashrc 5.linux中文显示,现在分享给大家,希望可以做个参考。

1.ls屏蔽波浪线~作为文件名结尾的文件

使用 -B 参数。

eg:ls -B

2.source命令  .点命令

转  http://blog.csdn.net/cscrazybing/article/details/49340507

  #!/bin/bash

        #cd2c.sh

         cd  /file/path

1.source命令和点(.)命令,其实是一回事,

例如我在当前目录下要执行一个shell脚本,source filename.sh 和

. ./filename.sh是一样的效果注意点命令中,第一个点和第二点中间有一个空格

2.source命令的详解

        source filename [arguments]  Read and execute commands from filename in the current shell environment and return the exit sta-  tus of the last command executed from filename. If filename does not contain a slash, file names  in PATH are used to find the directory containing filename. The file searched for in PATH need  not be executable. When bash is not in posix mode, the current directory is searched if no file  is found in PATH. If the sourcepath option to the shopt builtin command is turned off, the PATH  is not searched. If any arguments are supplied, they become the positional parameters when file-  name is executed. Otherwise the positional parameters are unchanged. The return status is the  status of the last command exited within the script (0 if no commands are executed), and false if  filename is not found or cannot be read.
source 命令会将filename的命令都读进当前的shell环境中,并且在当前的shell环境中执行,因此 source cd2c.sh 会得到预期的结果,因为cd2c.sh中的命令就是在当前的shell环境中执行的。

3,如果直接运行一个shell脚本又到底做了什么呢?


          在当前的shell环境中(我们称作父shell),如果执行一个shell脚本,会做下面几件事

          a,当前的shell进程(父shell)fork/exec一个子shell用于执行filename中命令,这个时候,父shell进程wait等待子shell返回。

          b,子shell读取命令,开始执行builtin命令cd。

          c,子shell读到文件末尾,终止执行推出,从新回到父shell进程。

           可以看到,在执行一个shell的时候,cd /file/path命令确实执行了,但是是在子shell进程中执行的,执行完毕后子shell终止并返回到父进程中了,所以这时候并我们到达的预期效果。

----------------------------------------------------------------------------------------------------------------------------------------------------------

4.bash

常常需要在~/.bashrc文件的末尾加上 export PATH=/PATH/TO/SDK_OR_JDK:$PATH 类是这样的命令,然后在source一下这个~/.bashrc

          man bash 我们会看到下面的解释:

           ~/.bashrc

          The individual per-interactive-shell startup file,可以看出,~/.bash是一个独立的shell环境的启动文件(或者说启动脚本)。

          下面来看看另一个文件 ~/.bash_profile,man bash 关于这个文件的解释如下:

          The personal initialization file, executed for login shells,

         ~/.bash_profile: 每个用户都可使用该文件输入专用于自己使用的shell信息,当用户登录时,该文件仅仅执行一次!默认情况下,他设置一些环境变量,执行用户的.bashrc文件。看重点,该文件仅仅在用户登录的时候执行一次,而且~/.bash_profile文件会去主动执行~/.bashrc。来看下该文件:

/*在我的电脑上,ubuntu11.04,~目录下没有.bash_profile取而代之的是.profile*/

           # exists.
           # see /usr/share/doc/bash/examples/startup-files for examples.
           # the files are located in the bash-doc package.

           # the default umask is set in /etc/profile; for setting the umask
           # for ssh logins, install and configure the libpam-umask package.
           #umask 022

          # if running bash
          if [ -n "$BASH_VERSION" ]; then
         # include .bashrc if it exists
         if [ -f "$HOME/.bashrc" ]; then
          .    "$HOME/.bashrc"    #注意看,点命令
          fi
          fi

           可以看到.profile文件有调用.bashrc,这样就保证我们之前修改过的.bashrc文件,在linux每次启动的时候都能被执行到。而.bashrc文件的内容在启动新的shell进程的时候会被执行。


----------------------------------------------------------------------------------------------------------------------------------------------------------


5.linux中文显示

 1.LANG环境变量

LANG环境变量是en_US.UTF-8字符集是utf-8 ,那么系统的菜单、程序的工具栏语言、输入法默认语言就都是英文的

LANG环境变量是zh_CN.UTF-8,字符集是utf-8

2.基于centos 不知道ubuntu是否可以

1、使用命令 LANG=编码,来修改当前的编码,来看哪个编码合适。

2、1中使用LANG进行的配置只是临时的,永久生效的配置在文件 /etc/sysconfg/i18n中。

4、如果使用的secure CRT进行ssh连接的话,注意将CRT的配置中的编码改成和Linux一样。

5、windows下默认用的gbk编码(应该是因为我们用的中文版的windows吧。。),所以如果有个文件在windows下是utf-8编码了、那么上传到linux后若显示乱码了,那么将LANG改为:zh_US.UTF-8或en_US.UTF-8(具体选哪个看你当时安装系统的时候选择的哪个语言版本了)




最后

以上就是含蓄大地最近收集整理的关于命令相关1.ls屏蔽波浪线~作为文件名结尾的文件 2.source命令  .点命令 4.bash常常需要在~/.bashrc文件的末尾加上 export PATH=/PATH/TO/SDK_OR_JDK:$PATH 类是这样的命令,然后在source一下这个~/.bashrc 5.linux中文显示的全部内容,更多相关命令相关1.ls屏蔽波浪线~作为文件名结尾的文件内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(58)

评论列表共有 0 条评论

立即
投稿
返回
顶部