Linux文件查看命令

head 查看文件前几行:head -100 /etc/passwd

tail 查看文件末尾几行:tail -100 /etc/passwd

sed 命令可以用来查看文件中间部分:sed -n "100,200p" /etc/passwd


Linux Command Line Tips

Moving around
Obviously, you can use the arrow keys to move around on the command line, but there are several other shortcuts:

  • CTRL+A = move cursor to beginning of line
  • CTRL+E = move cursor to end of line
  • CTRL+U = deletes everything before the cursor
  • CTRL+K = deletes everything after the cursor
  • CTRL+W = deletes the “word” before the cursor (all text up to the previous space)
  • CTRL+Y = paste previously deleted text (similar to undo and can be repeated)
  • CTRL+I = similar to tab but for whatever text your cursor is on
  • CTRL+L = similar to the “clear” command


从CVS中删除一个版本

删除版本1.3,并且保留版本1.2 
cvs admin -o1.3 foo

完全删除文件的所有版本
rm foo 
cvs remove foo
cvs commit "Delete no longer used file" foo


联想发布Thinkpad T400s

本月早些时候曝光的ThinkPad轻薄新机T400s终于正式揭开了面纱,联想今天在美国发布T400s并已经开始上线销售。

据联想介绍,T400s的设计源自极限轻薄机型X300,使用和X300同样的第二代镁合金/碳纤维防滚架技术,再加上LED背光液晶屏幕,固态硬盘的使用,打造出了一台拥有14.1寸大屏幕的超轻薄笔记本,厚度仅为0.83英寸(2.1厘米),含六芯电池的重量仅为3.91磅(1.77公斤)。

设计方面,联想对ThinkPad标志性的键盘设计进行了改进,增大了常用的Delete和Esc键面积,缩小了按键之间的空隙防止食物碎屑等落入其中。另外,新的大面积触控板支持多点触摸(两指)。200万像素摄像头、VOIP热键、大音量(T400两倍)扬声器的配置都为网络视频通讯提供了方便。

配置上,ThinkPad T400s使用了标准电压的小尺寸封装版Core 2 Duo处理器,最高频率2.53GHz。搭配最大128GB固态硬盘或250GB硬盘,内置9.5mm超薄DVD刻录机或蓝光光驱,提供 ExpressCard/34插槽或五合一读卡器,USB/eSATA整合接口,DisplayPort和VGA视频输出,网络连接包括以太网、WiFi 以及可选的WiMax、WWAN、蓝牙和UWB技术等。


Delete Comments

#! /usr/bin/perl

######################################################
# Delete comments
# Support comment tag:
#     1) /*…………………*/
#     2) ………./*………..*/
#     3) /*………..*/……….
#     4) …../*………..*/…..
#     5) //…………………..
#     6) ……….//………….
#     7) /*…………………..
#        …………………….
#        …………………….
#        …………………..*/
######################################################

die "Usage: del_comment.pl [file1 file2 file3 …]\n" unless ($ARGV[0] ne "") ;

foreach (@ARGV) {
  dc($_) ;
}

sub dc {
  $file_in  = shift ;
  $file_out = "${file_in}.out" ;
  if (open file_in,  "$file_in") {
    open file_out, ">$file_out" or die "Error: can not create an output file.\n" ;
    print "Info: Deleting comments in $file_in\n" ;
    $block_comment = 0 ;
    LINE: while(<file_in>) {
      next LINE if (/^\s*\/\*.*\*\/\s*$/) ;            # /*…………*/
      if (/^(.+)\/\*.*\*\/\s*$/) {                     # …./*……..*/
        print file_out "$1\n" ;
        next LINE ;
      }
      if (/^\s*\/\*.*\*\/(.+)$/) {                     # /*……..*/….
        print file_out "$1\n" ;
        next LINE ;
      }
      if (/^(.+)\/\*.*\*\/(.+)$/) {                    # ../*……..*/..
        print file_out "$1 $2\n" ;
        next LINE ;
      }
      if (/^\s*\/\/.*\*\/\s*$/) {                      # //…………*/
        print "\tEnd of a comment …\n" ;
        $block_comment — ;
        next LINE ;
      }
      next LINE if (/^\s*\/\//) ;                      # //…………..
      if (/^(.+)\/\//) {                               # ….//……….
        print file_out "$1\n" ;
        next LINE ;
      }
      if (/^\s*\/\*/) {                                # /*…………..
        print "\tStart of a comment …\n" ;
        $block_comment ++ ;
        next LINE ;
      }
      if (/\*\/\s*$/) {                                # …………..*/
        print "\tEnd of a comment …\n" ;
        $block_comment — ;
        next LINE ;
      }
      next LINE if ($block_comment > 0) ;
      print file_out $_ ;
    }
    warn "\tFatal: comment tags /* and */ are not paired.\n" unless ($block_comment == 0) ;
    close file_in ;
    close file_out ;
  }
  else {
    warn "Warning: can not open $file_in.\n" ;
  }
}


« Older Page