shell常用命令

来源:互联网 发布:软件代理招商方案 编辑:程序博客网 时间:2024/06/07 00:41
1. $0当前路径
2. basename  /usr/local/test.sh  ->test.sh
    dirname     /usr/local/test.sh   ->/usr/local
3. 两个文件合并 cat file1 file2  >>hold_file
4. 读入文件
    cat filename | while read line
    do
        echo $line
    done
5.压缩为.Z文件,原文件不存在
  compress filename -v
  uncompress filename.Z
6. 比较文件的不同
  diff filename1 filename2 -c  标准输出
7.占用块大小  512字节
   du -a/-s
8.文件属性
  file  filename
9.显示文件前几行
 head -20 filename
10.显示登录名
  logname
11.显示文件行号
    nl  filename
    cat filename | wc -l
12.保存会话信息,不知道干什么用的
   script  mylogfile
13.更新时间戳 文件创建时间
   touch filename
14.whereis
15.显示当前终端
  tty
0 0
原创粉丝点击