最簡單的,我們直接使用more命令
[changyongid@localhost ~]$ more /proc/cpuinfo
空格下一頁,b上一頁。。按h看下。
Most commands optionally preceded by integer argument k. Defaults in brackets.
Star (*) indicates argument becomes new default.
------------------------------------------------------------------------------- Display next k lines of text [current screen size] 顯示下k行,k即我們上面的行數參數。
z Display next k lines of text [current screen size]* 試了一下,跟上面差不多。 Display next k lines of text [1]*
d or ctrl-D Scroll k lines [current scroll size, initially 11]* 這個不太清楚,我試了一下,好像下滾半頁。
q or Q or Exit from more 退出more
s Skip forward k lines of text [1]
f Skip forward k screenfuls of text [1]
b or ctrl-B Skip backwards k screenfuls of text [1]
' Go to place where previous search started
= Display current line number
/ Search for kth occurrence of regular expression [1]
n Search for kth occurrence of last r.e [1]
! or :! Execute in a subshell
v Start up /usr/bin/vi at current line 這里按下v會有驚喜,一直就進入vi了,而且光標是停在當前行的
ctrl-L Redraw screen 刷新
:n Go to kth next file [1]
:p Go to kth previous file [1]
:f Display current file name and line number
. Repeat previous command
有些命令跟vi里面相似。。。不啰嗦了。作者: changyongid 時間: 2009-9-1 09:04
來看下命令本身的參數。
-d 提示使用者,在畫面下方顯示 [Press space to continue, 'q' to quit.] ,如果使用者按錯鍵,則會顯示 [Press 'h' for instructions.] 而不是 '嗶' 聲
-l 取消遇見特殊字元 ^L(送紙字元)時會暫停的功能
-f 計算行數時,以實際上的行數,而非自動換行過后的行數(有些單行字數太長的會被擴展為兩行或兩行以上)
-p 不以卷動的方式顯示每一頁,而是先清除螢幕后再顯示內容
-c 跟 -p 相似,不同的是先顯示內容再清除其他舊資料
-s 當遇到有連續兩行以上的空白行,就代換為一行的空白行
-u 不顯示下引號 (根據環境變數 TERM 指定的 terminal 而有所不同)
+/ 在每個檔案顯示前搜尋該字串(pattern),然后從該字串之后開始顯示
+num 從第 num 行開始顯示
-? ........ --help
Display help (from command line).
-c ........ --clear-screen
Repaint by clearing rather than scrolling. 從頂部(從上到下)刷新屏幕,并顯示文件內容。而不是通過底部滾動完成刷新;
-f ........ --force
Force open non-regular files. 強制打開文件,二進制文件顯示時,不提示警告;
-i ........ --ignore-case
Ignore case in searches that do not contain uppercase. 搜索時忽略大小寫;除非搜索串中包含大寫字母;
-I ........ --IGNORE-CASE
Ignore case in all searches. 搜索時忽略大小寫,除非搜索串中包含小寫字母;
-m -M .... --long-prompt --LONG-PROMPT
Set prompt style. 顯示讀取文件的百分比;
-n -N .... --line-numbers --LINE-NUMBERS
Don't use line numbers. 在每行前輸出行號;
-p [pattern] --pattern=[pattern]
Start at pattern (from command line).pattern 搜索pattern;比如在/etc/profile搜索單詞MAIL,就用 less -p MAIL /etc/profile
less命令的動作有些跟vi里面是一樣的。。。
j 向下滾一行
k 向上滾一行
y 也是向上滾一行
g 跳到第一行
G 跳到最后一行
u 向上滾半屏
d 向下滾半屏
b 向上滾一頁
空格 向下滾一頁
/word 搜索某個詞
v 調用vi
p n% 跳到n%,比如 10%,也就是說比整個文件內容的10%處開始顯示;作者: changyongid 時間: 2009-9-2 09:54
其實,less跟more還是有挺大區別的。。
例如我們在終端里用more命令,顯示出來的東西是直接打在終端里的,即使我們退出more,那顯示出來的字符串都會留在終端里。。。
而less更像是一個編輯器,例如
less +5 ttt 從第五行開始顯示ttt文件的內容,相當于新打開了一個頁面顯示這些內容,當退出時,又退回到原來的終端里,而那些內容不會留在終端上。作者: changyongid 時間: 2009-9-3 09:57
今天特殊一點,來學兩個命令,因為這兩個命令比較簡單。。
head tail
跟以上的各命令類似,這兩個命令也是查看文件內容用的。
head :查看文件開頭的一些內容,而不是查看整個文件。這樣的話,我們通過看文件開頭的一點內容人就可以大概了解這個文件的內容。。
語法:head [- 參數] 文件
-c, --bytes=[-]N print the first N bytes of each file; 查看文件開頭的n個字節內容
with the leading `-', print all but the last
N bytes of each file
-n, --lines=[-]N print the first N lines instead of the first 10;查看文件開頭n行的內容,不帶參數時默認顯示前十行內容
with the leading `-', print all but the last
N lines of each file
-q, --quiet, --silent never print headers giving file names
-v, --verbose always print headers giving file names
--help 顯示此幫助信息并退出
--version 輸出版本信息并退出作者: changyongid 時間: 2009-9-3 10:00 本帖最后由 changyongid 于 2009-9-3 10:06 編輯
[changyongid@localhost src]$ od --help
Usage: od [OPTION]... [FILE]...
or: od [-abcdfilosx]... [FILE] [[+]OFFSET[.]]
or: od --traditional [OPTION]... [FILE] [[+]OFFSET[.] [+][LABEL][.]]
Write an unambiguous representation, octal bytes by default,
of FILE to standard output. With more than one FILE argument,
concatenate them in the listed order to form the input.
With no FILE, or when FILE is -, read standard input.
All arguments to long options are mandatory for short options.
-A, --address-radix=RADIX decide how file offsets are printed 指定地址基數,這里的RADIX在help下面有詳細的解釋。
-j, --skip-bytes=BYTES skip BYTES input bytes first
-N, --read-bytes=BYTES limit dump to BYTES input bytes
-S, --strings[=BYTES] output strings of at least BYTES graphic chars
-t, --format=TYPE select output format or formats 數據顯示格式 ,同樣的,TYPE在help的下面也有詳細的解釋。
-v, --output-duplicates do not use * to mark line suppression
-w, --width[=BYTES] output BYTES bytes per output line
--traditional accept arguments in traditional form
--help 顯示此幫助信息并退出
--version 輸出版本信息并退出
我們比較常用的就是-A 和 -t參數了。。
RADIX的說明如下:
RADIX is d for decimal, o for octal, x for hexadecimal or n for none.
即:
d -十進制
o -八進制
x -十六進制
n -不打印偏移植
TYPE的說明如下:
TYPE is made up of one or more of these specifications:
a named character, ignoring high-order bit
c ASCII character or backslash escape ASCII字符或反斜杠序列
d[SIZE] signed decimal, SIZE bytes per integer有符號十進制數
f[SIZE] floating point, SIZE bytes per integer浮點數
o[SIZE] octal, SIZE bytes per integer八進制(系統默認值為02)
u[SIZE] unsigned decimal, SIZE bytes per integer無符號十進制數
x[SIZE] hexadecimal, SIZE bytes per integerx 十六進制數
不過,還是繼續的好。。說好一天一個的。。。呆會更新。。。謝謝支持。作者: changyongid 時間: 2009-9-7 08:24
周末停了兩天。 宿舍里不是很方便。。。。作者: changyongid 時間: 2009-9-7 08:27
前面我們學習了幾個查看文件內容的命令。會用這幾個命令,查看一般的文件內容也就夠用了。。。
那么,接下來學習一個命令,用于文件內容的統計。。。作者: changyongid 時間: 2009-9-7 08:36
這個命令就是 wc 我們先來help一下。
[changyongid@localhost ~]$ wc --help
用法:wc [選項]... [文件]...
或:wc [選項]... --files0-from=F
Print newline, word, and byte counts for each FILE, and a total line if
more than one FILE is specified. With no FILE, or when FILE is -,打印文件的行、字、字節數
read standard input. 沒有指定文件時,則從標準輸入讀取
-c, --bytes print the byte counts字節數
-m, --chars print the character counts 這個好像也是字節數
-l, --lines print the newline counts行數
--files0-from=F read input from the files specified by
NUL-terminated names in file F;
If F is - then read names from standard input
-L, --max-line-length print the length of the longest line 最長行的長度
-w, --words print the word counts字數
--help 顯示此幫助信息并退出
--version 輸出版本信息并退出作者: changyongid 時間: 2009-9-7 08:48
現在來試一下這個命令。。。有名為 tt 的一個文件。。我們來對其操作一下。。
可以看到,這個命令的參數非常的簡單。作者: changyongid 時間: 2009-9-8 21:45
繼續來看。 help得到的信息很少,那么就man一下。。 截取一些有用的信息。
Change the current directory to dir. The variable HOME is the
default dir.
The -P option says to use the physical directory structure instead of
following symbolic links (see also the -P option to the set
builtin command); the -L option forces symbolic links to be fol-
lowed. An argument of - is equivalent to $OLDPWD.
長選項必須用的參數在使用短選項時也是必需的。
-m, --mode=MODE set file mode (as in chmod), not a=rwx - umask 對新建目錄設置存取權限
-p, --parents no error if existing, make parent directories as needed 如果路徑中有個目錄不存在,則創建它
-v, --verbose print a message for each created directory 會顯示出提示信息。這個選項許多命令里都會有。大至是一個提示的作用,讓我們用戶可以看到操作的結果。
-Z, --context=CTX set the SELinux security context of each created
directory to CTX
--help 顯示此幫助信息并退出
--version 輸出版本信息并退出作者: changyongid 時間: 2009-9-10 15:50
來試一下。。做幾個例子就會用了。。作者: changyongid 時間: 2009-9-10 15:57
[changyongid@localhost ~]$ pwd
/home/changyongid
現在在我們用戶的主目錄下
建立一個名為a的目錄
[changyongid@localhost ~]$ mkdir a
然后ls -d 一下,就可以看到a這個目錄了。ls -d 是列出當前路徑下的目錄。
我仍然會偶爾夢見學校,夢見那些可愛的同學們。
我還是沒有適應完全離開作者: changyongid 時間: 2009-9-13 18:38
[changyongid@Fedora ~]$ rmdir --help
Usage: rmdir [OPTION]... DIRECTORY...
rmdir 選項... 目錄....
Remove the DIRECTORY(ies), if they are empty.
如果目錄是空的話,則刪除這個目錄
--ignore-fail-on-non-empty
ignore each failure that is solely because a directory
is non-empty
忽略任何因目錄為非空而造成的錯誤
-p, --parents remove DIRECTORY and its ancestors; e.g., `rmdir -p a/b/c' is
similar to `rmdir a/b/c a/b a'
刪除指定的目錄,若該目錄的上層目錄變成了空目錄,則一并刪除
-v, --verbose output a diagnostic for every directory processed
顯示指定執行的過程
--help display this help and exit
顯示幫助信息,并退出
--version output version information and exit
輸出版本信息,并退出
-g 如 -l,但不顯示所屬用戶
--group-directories-first
group directories before files.
augment with a --sort option, but any
use of --sort=none (-U) disables grouping
-G, --no-group 不顯示組信息
-h, --human-readable with -l, print sizes in human readable format
(e.g., 1K 234M 2G)
作者: changyongid 時間: 2009-9-15 09:25
OH shit!
I can not input chinese now,and i am sorry for my poor english.作者: changyongid 時間: 2009-9-16 08:36
it is ok now!作者: changyongid 時間: 2009-9-16 08:51
cp
格式:cp [OPTION]... [-T] SOURCE DEST
cp [OPTION]... SOURCE... DIRECTORY
cp [OPTION]... -t DIRECTORY SOURCE...
-m, --magic-file LIST use LIST as a colon-separated list of magic
number files
-z, --uncompress 試著探測壓縮文件類型
-b, --brief 打印輸時不打印文件名
-c, --checking-printout 打印輸出分析的詳細過程。與m連用,便于調試所用。