Feb 25, 2008
在 linux/unix 中可以使用 join 命令来连接两个文件。它会根据指定栏位,找到两个文件中指定栏位内容相同的行,将他们合并,并根据要求的格式输出内容。该命令对于比较两个文件的内容很有帮助。
语法 join [ -i ][ -a filenumber | -v filenumber ] [ -1 fieldnumber ]
[ -2 fieldnumber ] [ -o list ] [ -e string ] [ -t char ]
file1 file2
主要参数
-i 或 --igore-case 比较栏位内容时,忽略大小写的差异。
-a <1或2> 除了显示原来的输出内容之外,还显示指令文件中没有相同栏位的行。
-v <1或2> 跟-a相同,但是只显示文件中没有相同栏位的行。
-1/-j1 <栏位> 连接[文件1]指定的栏位。栏位从 1 开始,默认为1。
-2/-j2 <栏位> 连接[文件2]指定的栏位。栏位从 1 开始,默认为1。
-j <栏位> 相当于 -1 <栏位> -2 <栏位>
-e <字符串> 若[文件1]与[文件2]中找不到指定的栏位,则在输出中填入选项中的字符串。
-o <格式> 按照指定的格式来显示结果。
-t <字符> 使用栏位的分隔字符。
--help 显示帮助。
--version 显示版本信息。
实例
oracle DBALNP01@lonespcmp1 > cat timestamp_list_LNWASP1_pre.out.es
Feb 22 14:53 /data/oracle/LNWASP1/data1/LNWASP1_QUEST_SMALL1_DATA_01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/data1/LNWASP1_audits01.dbf
Feb 22 14:54 /data/oracle/LNWASP1/data1/LNWASP1_data01_01.dbf
Feb 22 14:54 /data/oracle/LNWASP1/data1/LNWASP1_index01_01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/data1/LNWASP1_tools_01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/data1/LNWASP1_users_01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/index1/LNWASP1_sysaux02.dbf
Feb 22 14:53 /data/oracle/LNWASP1/index1/LNWASP1_sysaux03.dbf
Feb 22 14:54 /data/oracle/LNWASP1/redo1/LNWASP1_ctl_01.dbf
Feb 22 14:54 /data/oracle/LNWASP1/redo2/LNWASP1_ctl_02.dbf
Feb 22 14:54 /data/oracle/LNWASP1/redo3/LNWASP1_ctl_03.dbf
Feb 22 14:54 /data/oracle/LNWASP1/rollback/LNWASP1_undotbs01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/system/LNWASP1_sysaux01.dbf
Feb 22 14:53 /data/oracle/LNWASP1/system/LNWASP1_system01.dbf
Feb 22 05:06 /data/oracle/LNWASP1/temp/LNWASP1_temp01.dbf
(/apps/oracle/scripts/ADHOC/DOBCPFILETSCHECK/tmp)
oracle DBALNP01@lonespcmp1 > cat timestamp_list_LNWASP1_post.out.es
Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_QUEST_SMALL1_DATA_01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_audits01.dbf
Feb 22 14:58 /data/oracle/LNWASP1/data1/LNWASP1_data01_01.dbf
Feb 22 14:58 /data/oracle/LNWASP1/data1/LNWASP1_index01_01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_tools_01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_users_01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/index1/LNWASP1_sysaux02.dbf
Feb 22 14:57 /data/oracle/LNWASP1/index1/LNWASP1_sysaux03.dbf
Feb 22 14:58 /data/oracle/LNWASP1/redo1/LNWASP1_ctl_01.dbf
Feb 22 14:58 /data/oracle/LNWASP1/redo2/LNWASP1_ctl_02.dbf
Feb 22 14:58 /data/oracle/LNWASP1/redo3/LNWASP1_ctl_03.dbf
Feb 22 14:58 /data/oracle/LNWASP1/rollback/LNWASP1_undotbs01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/system/LNWASP1_sysaux01.dbf
Feb 22 14:57 /data/oracle/LNWASP1/system/LNWASP1_system01.dbf
Feb 22 05:06 /data/oracle/LNWASP1/temp/LNWASP1_temp01.dbf
(/apps/oracle/scripts/ADHOC/DOBCPFILETSCHECK/tmp)
oracle DBALNP01@lonespcmp1 > join -1 4 -2 4 -o 1.1 1.2 1.3 2.1 2.2 2.3 2.4 timestamp_list_LNWASP1_pre.out.es timestamp_list_LNWASP1_post.out.es
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_QUEST_SMALL1_DATA_01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_audits01.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/data1/LNWASP1_data01_01.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/data1/LNWASP1_index01_01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_tools_01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/data1/LNWASP1_users_01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/index1/LNWASP1_sysaux02.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/index1/LNWASP1_sysaux03.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/redo1/LNWASP1_ctl_01.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/redo2/LNWASP1_ctl_02.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/redo3/LNWASP1_ctl_03.dbf
Feb 22 14:54 Feb 22 14:58 /data/oracle/LNWASP1/rollback/LNWASP1_undotbs01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/system/LNWASP1_sysaux01.dbf
Feb 22 14:53 Feb 22 14:57 /data/oracle/LNWASP1/system/LNWASP1_system01.dbf
Feb 22 05:06 Feb 22 05:06 /data/oracle/LNWASP1/temp/LNWASP1_temp01.dbf
参考
http://www.linuxmanpages.com/man1/join.1.php
http://www.allwiki.com/index.php?title=Linux%E5%91%BD%E4%BB%A4:Join&variant=zh-cn
Posted by Sky at 05:29 PM | Permalink | comments(0) | OS
Jul 26, 2007
vi/vim 中可以使用 :s 命令来替换字符串。以前只会使用一种格式来全文替换,今天发现该命令有很多种写法(vi 真是强大啊,还有很多需要学习),记录几种在此,方便以后查询。
:s/vivian/sky/ 替换当前行第一个 vivian 为 sky
:s/vivian/sky/g 替换当前行所有 vivian 为 sky
:n,$s/vivian/sky/ 替换第 n 行开始到最后一行中每一行的第一个 vivian 为 sky
:n,$s/vivian/sky/g 替换第 n 行开始到最后一行中每一行所有 vivian 为 sky
n 为数字,若 n 为 .,表示从当前行开始到最后一行
:%s/vivian/sky/(等同于 :g/vivian/s//sky/) 替换每一行的第一个 vivian 为 sky
:%s/vivian/sky/g(等同于 :g/vivian/s//sky/g) 替换每一行中所有 vivian 为 sky
可以使用 # 作为分隔符,此时中间出现的 / 不会作为分隔符
:s#vivian/#sky/# 替换当前行第一个 vivian/ 为 sky/
Posted by Sky at 12:07 AM | Permalink | comments(4) | OS
Jun 13, 2007
时间
所有 UNIX 系统都采用格林威治时间从1970-01-01午夜后开始计算的微秒数来保存时间,这一日期通常称为 epoch,正值表示为 1970 以后,负值则表示 1970 年以前。
时间刷新频率由 /usr/include/sys/param.h 中的 HZ 常量决定,该值决定了系统的时间精度,在 Solaris 中的定义:
#define HZ ((clock_t)_sysconf(_SC_CLK_TCK))
_SC_CLK_TCK 表示每秒的 clock ticks 数,也称为嘀嗒数
由于所有 UNIX 系统都按照 epoch 来计算时间,对于 32bit 的 UNIX 系统时间范围为 1901.9042 ~ 2038.0958,这可能造成系统或者应用程序的问题,参考 eygle 的文章:
Oracle与Linux/Unix下的时间处理 Oracle诊断案例-Job任务停止执行
时区
TZ 环境变量保存当前时区,在安装系统过程会要求设置一个默认时区。/usr/lib/zoneinfo 目录和其子目录中保存了所有支持的时区信息(Solaris 时区信息保存在 /usr/share/lib/zoneinfo 中)。TZ 环境变量的值必须包含在这些时区文件中,如果设置错误将会被重置为格林威治标准时间。
在 Solaris 中可以通过修改 /etc/default/init 文件中的 TZ 值来修改默认的时区。为了兼容早期版本,可以为该文件建立一个字符连接:/etc/TIMEZONE。该文件的格式为每行一条 VAR=value,VAR 必须是 TZ, LANG, CMASK 和任何 LC_* 环境变量。
参考:http://bbs.chinaunix.net/viewthread.php?tid=877273
显示时间
所有 UNIX 系统中都有 date 程序,用来显示系统时钟。date 程序会根据 TZ 环境变量显示合适的时间。
oracle DBALNP01 > echo $TZ
GB-Eire
oracle DBALNP01 > date
Wed Jun 13 07:54:38 BST 2007
oracle DBALNP01 > TZ=PRC
oracle DBALNP01 > echo $TZ
PRC
oracle DBALNP01 > date
Wed Jun 13 14:55:04 CST 2007
此外,可以指定 date 的显示格式,语法:
date + format
其中 format 必须是一个词,所以对于包含空白的 format 参数需要用引号包起来
oracle DBALNP01 > date +%y%m%d
070613
format 参数可以参考:
http://www.heysky.net/digest/2007/04/date_format.html
Posted by Sky at 03:18 PM | Permalink | OS
May 24, 2007
All colleagues must log into the Windows terminals to do their jobs in my new corporation. There are only several servers and all colleagues work on them, so sometimes we will be kicked out of the server. It always makes us depressed. And sometimes when I re-log into the server, I can't start Lotus Notes. Because the application is running, though I have been kicked out.
I have encountered this kind of situation several times, so I want to find a way to resolve it. With google I find several useful windows command which I did not familiarize.
msg.exe: Send a message to a user local or remote. This is command is used frequently.
msg username [/SERVER:servername] message
Send message to username on servernameqprocess.exe: Display information about processes local or remote = query process
qprocess username [/SERVER:servername]
Display all processes beloned to username on servername
query.exe: Query TERMSERVER user process and sessions
quser.exe: Display information about a user logged on = query user
tsdiscon.exe: Disconnect a user from a terminal session
TSDISCON [sessionid | sessionname] [/SERVER:servername] [/V]
tskill.exe: Kill a Terminal server process
TSKILL processid | processname [/SERVER:servername] [/ID:sessionid | /A] [/V]
logoff.exe: Log user off
LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V]
All the commands have an optional parameter: /SERVER:servername. It is useful to operate other server.
Posted by Sky at 11:04 PM | Permalink | comments(1) | OS
Apr 06, 2007
I have used Windows 2003 for several years and it works well all the time. I don't need to worry about the update. But it frequently popped up bluescreen since last year. And I found it relates to my hard disks. When I take down my two pata hard disks, the system works smoothly. I am too lazy to find out the cause or reinstall the OS. So I have used the only sata hard disk for several months.
Last week, I wanted to use the important documents in the other two hard disks. So I decide to reinstall the OS, and this time I choose WindowsXP. It is the second time that I install WindowsXP on my own computer. I found WindowsXP's performance is not as good as Windows2003 at the first time, and I uninstalled it finally. But this time I have no choice. I want to use the other two hard disk.
Installing WindowsXP is easy. But you should do something before and after reinstalling OS. For example, backup the important data on the system driver before reinstalling and do some tuning after reinstalling. You can get some tips from "reinstall_xp_memo ".
Another problem is windows update. I think most of individual windows users in China use the piratic Windows os and Microsoft enacted a program called Windows Genuine Advantage to stop this action. I wrote a web log about how to crack the KB892130 before. But after that, Microsoft released several hotfixes. There are two cracks for version 1.7.0018.1 and 1.7.0018.5 . Find out the version of LegitCheckControl.dll and use the corresponding crack. If you wouldn't like to let WgaTray.exe be run automatically, delete the key of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify\WgaLogon in registry.
Installing wmp11 should also pass the WGA program which is different from the one above. You can bypass the WGA program using the method followed.
1. Download the WMP11 installing file and extract it
2. Execute the files in sequence: wmfdist11.exe, wmdbexport.exe, umdf.exe, wmp11.exe
Everything has been done! Now all my hard disks can work and it has not popped up bluescreen yet.
Posted by Sky at 09:57 PM | Permalink | comments(0) | OS