Sunday, September 30, 2007

emacs: how to delete a block of region

Mark (Ctrl+Space) the beginning of first line and move cursor to the the last line, and move it to the right n chars. Then do “Alt+x kill-rectangle” (Ctrl+x r k). This command can be used to delete any rectangular block of text, not just at the beginning of lines.

From: http://xahlee.org/emacs/emacs.html

Tuesday, September 25, 2007

Linux:command: vim

  加密和解密
  
  加密和解密文件
  
  在命令模式输入“:X”命令,接着输入密码、确认输入密码,最后输入“:wq”命令保存退出。文件就已经被加密了。
  
  经过上面方法加密后的文件变成密文文件。要阅读原来的明文,则在打开文件后,会提示用户输入密码。如果密码输入正确,就能看到原来的明文。另外可以看到,在最后的状态行上有此文件已被加密的提示。

需要什么来搜一搜吧so.bitsCN.com

  
  取消加密
  
  取消加密的方法很简单。在命令模式输入“:X”命令,首先会提示输入密码,这时直接敲回车键。接下来在提示重复输入密码时也直接敲回车键,最后输入“:wq”命令保存退出。这样文件的加密就被取消了。
  
  注意,以上加密方法是运行在Red Hat Linux 9.0上的vim中。在其它平台可能略有差异,请以实际平台或版本的帮助为准。
From http://www.bitscn.com/linux/command/200604/6563.html

Linux:command: some useful text commands

uniq
  (=unique-----唯一的)去掉已排序的文件中的重复行。例如:sort myfile | uniq

fold –w 30 –s my_file.txt > new_file.txt
  用空格将文本文件 my_file.txt 中的每行截成30个字符,并输出到 new_file.txt.

fmt –w 75 my_file.txt > new_file.txt
  格式化文件中的每行为75个字符。把超过75个字符的行截短,把少于75个字符的行补齐,但不会移去空行。

nl myfile > myfile_lines_numbered
  给文件 myfile 的每行标上行号。把结果输出给文件 myfiles_lines_numbered。

indent –kr –i8 –ts8 –sob –l80 –ss –bs –psl “$@” *.c
  通过插入或删除空格来改变“C”源码的外观。上面例子里格式的选项是和 Linux 内核的源码的风格是一至的(script /usr/src/linux/scripts/Lindent)。 看 man indent 来了解各个选项的意义。存在的文件先被备份然后就被格式化好的文件给替代了。

rev filename > filename1
  打印文件 filename,每行字符以相反顺序显示。上面的例子里结果直接输入到文件 filename1。

shred filename
  用垃圾字符重复并覆盖文件 filename 的内容,使任何人都无法再去阅读文件的内容。

paste file1 file2 > file3
  按行把两个或多个文件合并,用作默认分界符(用选项”d=”来选择自己的分界符)。

如果文件 file1 的内容是:
1
2
3

并且文件 file2 的是:
a
b
c
d

那么结果 file3 里的内容就该是:

1 a
2 b
3 c
d

join file1 file2 > file3

  把两个文本文件里有相同域的行连成一行。Join 和数据库的“表连接”操作是类似的,但它只是对两个文本文件进行操作。默认的分界符是空格。如果你想用其它的操作符,你可用 man join 去查看里面的选项。

如果 file1 里的内容是:

1 Barbara
2 Peter
3 Stan
4 Marie

并且 file2 的是:
2 Dog
4 Car
7 Cat

那么结果 file3 就该是:
2 Peter Dog
4 Marie Car

des –e plain_file encrypted_file
  (=”Data Encryption Standard” 数据加密标准)加密文件 plain_file。你会被要求输入一个键值用于加密算法使用。加密后的结果存放到文件“encrypted_file”。解密就用:
des –d encrypted_file decrypted_file.

gpg
  “Gnu Privacy Guard-----GNU 的私人警卫”—一个和 PGP(“Pretty Good Privacy”)功能一样的免费软件。gpg 比 PGP 更安全并且没有使用有专利的算法。gpg 主要用于给你的 email 加签名并且检查其它信息的签名。你也可用它来给你的信息加密解密。http://www.gnupg.org/上有所有的详细信息,包括一个易读和详细的手册。

   开始,我需要一对匙值:个人匙和公共匙。个人匙用于给我的信息签字。公共匙用于传给他人来确认我的信息的签名在他们收到我的信息后来确认我的信息的签 字。(某人还可用公共匙来给信息加密这样这个信息就只能通过我的个人匙加密并阅读)。我用下面的命令来生成这一对匙值:

from http://www.networkdictionary.cn/software/Linux75.php

Tuesday, September 18, 2007

Linux:command: use chown to change owner of a file or directory

The command chown is used to change the owner of a file/directory. For example:
chown -hR zhiyil:zhiyil /work
(change owner of /work to zhiyil and group is zhiyil either)

Locations of visitors to this page