time 指令 !
會顯示 執行的 時間 列表 !!!
ex
time /.a.out
會顯示出
4. real 0m0.136s
5. user 0m0.010s
6. sys 0m0.070s
類似這樣的結果
2012年3月25日 星期日
2012年3月20日 星期二
pid_t
http://www.delorie.com/gnu/docs/glibc/libc_566.html
26.3 Process Identification
The pid_t data type represents process IDs. You can get the process ID of a process by calling getpid. The function getppid returns the process ID of the parent of the current process (this is also known as the parent process ID). Your program should include the header files `unistd.h' and `sys/types.h' to use these functions.
Data Type: pid_t
The pid_t data type is a signed integer type which is capable of representing a process ID. In the GNU library, this is an int.
Function: pid_t getpid (void)
The getpid function returns the process ID of the current process.
Function: pid_t getppid (void)
The getppid function returns the process ID of the parent of the current process.
26.3 Process Identification
The pid_t data type represents process IDs. You can get the process ID of a process by calling getpid. The function getppid returns the process ID of the parent of the current process (this is also known as the parent process ID). Your program should include the header files `unistd.h' and `sys/types.h' to use these functions.
Data Type: pid_t
The pid_t data type is a signed integer type which is capable of representing a process ID. In the GNU library, this is an int.
Function: pid_t getpid (void)
The getpid function returns the process ID of the current process.
Function: pid_t getppid (void)
The getppid function returns the process ID of the parent of the current process.
2012年2月8日 星期三
2012年2月7日 星期二
Linux 改背景顏色
再寫 C /C ++ 得時候 有時候看不清楚註解
如何更改註解顏色
方法如下
vim 的 config 檔在以下
整體 vim 的設定值一般是放置在 /etc/vimrc 這個檔案,不過,不建議你修改他! 你可以修改 ~/.vimrc 這個檔案 (預設不存在,請你自行手動建立!),將你所希望的設定值寫入! 舉例來說,可以是這樣的一個檔案:
set bg=dark
即可
詳細的操作 請參考
鳥哥私房菜 !
http://linux.vbird.org/linux_basic/0310vi.php#vim_set
如何更改註解顏色
方法如下
vim 的 config 檔在以下
整體 vim 的設定值一般是放置在 /etc/vimrc 這個檔案,不過,不建議你修改他! 你可以修改 ~/.vimrc 這個檔案 (預設不存在,請你自行手動建立!),將你所希望的設定值寫入! 舉例來說,可以是這樣的一個檔案:
set bg=dark
即可
詳細的操作 請參考
鳥哥私房菜 !
http://linux.vbird.org/linux_basic/0310vi.php#vim_set
2012年2月6日 星期一
2012年2月1日 星期三
sed 指令使用
如何使用 sed
sed 是用來 排序的指令
例如說
一筆資料 data
1
2
3
4
5
cat data |sed '3d'
會顯示
1
2
4
5
[root@www ~]# nl /etc/passwd | sed '2,5d'
1 root:x:0:0:root:/root:/bin/bash
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
若是要刪除第 3 到最後一行,則是『 nl /etc/passwd | sed '3,$d' 』的啦,那個錢字號『 $ 』代表最後一行!
範例三:在第二行後面加入兩行字,例如『Drink tea or .....』與『drink beer?』
[root@www ~]# nl /etc/passwd | sed '2a Drink tea or ......\
> drink beer ?'
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
Drink tea or ......
drink beer ?
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
範例四:我想將第2-5行的內容取代成為『No 2-5 number』呢?
[root@www ~]# nl /etc/passwd | sed '2,5c No 2-5 number'
1 root:x:0:0:root:/root:/bin/bash
No 2-5 number
6 sync:x:5:0:sync:/sbin:/bin/sync
.....(後面省略).....
範例五:僅列出 /etc/passwd 檔案內的第 5-7 行
[root@www ~]# nl /etc/passwd | sed -n '5,7p'
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
範例六 取代字串
sed 's/要被取代的字串/新的字串/g'
ex
[Andy@ed520-RAID project1]$ cat sort
Ka123456789 line1
Ka987654321 line2
Ka555555555 line3
Ka135798642 line4
Ka246810951 line5
[Andy@ed520-RAID project1]$ cat sort |sed 's/Ka/Andy/g'
Andy123456789 line1
Andy987654321 line2
Andy555555555 line3
Andy135798642 line4
Andy246810951 line5
事實上 沒有寫g 好像也會自動替代
.....(後面省略).....
sed 是用來 排序的指令
例如說
一筆資料 data
1
2
3
4
5
cat data |sed '3d'
會顯示
1
2
4
5
[root@www ~]# nl /etc/passwd | sed '2,5d'
1 root:x:0:0:root:/root:/bin/bash
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
若是要刪除第 3 到最後一行,則是『 nl /etc/passwd | sed '3,$d' 』的啦,那個錢字號『 $ 』代表最後一行!
範例三:在第二行後面加入兩行字,例如『Drink tea or .....』與『drink beer?』
[root@www ~]# nl /etc/passwd | sed '2a Drink tea or ......\
> drink beer ?'
1 root:x:0:0:root:/root:/bin/bash
2 bin:x:1:1:bin:/bin:/sbin/nologin
Drink tea or ......
drink beer ?
3 daemon:x:2:2:daemon:/sbin:/sbin/nologin
範例四:我想將第2-5行的內容取代成為『No 2-5 number』呢?
[root@www ~]# nl /etc/passwd | sed '2,5c No 2-5 number'
1 root:x:0:0:root:/root:/bin/bash
No 2-5 number
6 sync:x:5:0:sync:/sbin:/bin/sync
.....(後面省略).....
範例五:僅列出 /etc/passwd 檔案內的第 5-7 行
[root@www ~]# nl /etc/passwd | sed -n '5,7p'
5 lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin
6 sync:x:5:0:sync:/sbin:/bin/sync
7 shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
範例六 取代字串
sed 's/要被取代的字串/新的字串/g'
ex
[Andy@ed520-RAID project1]$ cat sort
Ka123456789 line1
Ka987654321 line2
Ka555555555 line3
Ka135798642 line4
Ka246810951 line5
[Andy@ed520-RAID project1]$ cat sort |sed 's/Ka/Andy/g'
Andy123456789 line1
Andy987654321 line2
Andy555555555 line3
Andy135798642 line4
Andy246810951 line5
事實上 沒有寫g 好像也會自動替代
.....(後面省略).....
訂閱:
意見 (Atom)