欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Linux文本查看命令及其選項詳解(cat,head,tail)

 更新時間:2020年08月28日 08:36:21   作者:Philbert  
這篇文章主要介紹了Linux文本查看命令及其選項詳解(cat,head,tail),本文給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下

linux系統(tǒng)內(nèi)置命令可以通過以下兩種方式查詢:“cat --help” 或者“man cat”。

cat命令的常用選項和官方解釋如下:

cat file_name 顯示文件全部內(nèi)容

cat -b file_name 顯示文件非空行內(nèi)容

cat -E file_name 在文件每行末尾顯示$,常用于管道功能

cat -n file_name 顯示內(nèi)容和行號

Usage: cat [OPTION]... [FILE]...
Concatenate FILE(s) to standard output.

With no FILE, or when FILE is -, read standard input.

 -A, --show-all      equivalent to -vET
 -b, --number-nonblank  number nonempty output lines, overrides -n
 -e            equivalent to -vE
 -E, --show-ends     display $ at end of each line
 -n, --number       number all output lines
 -s, --squeeze-blank   suppress repeated empty output lines
 -t            equivalent to -vT
 -T, --show-tabs     display TAB characters as ^I
 -u            (ignored)
 -v, --show-nonprinting  use ^ and M- notation, except for LFD and TAB
   --help   display this help and exit
   --version output version information and exit

Examples:
 cat f - g Output f's contents, then standard input, then g's contents.
 cat    Copy standard input to standard output.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: http://www.gnu.org/software/coreutils/cat

head命令及其選項如下:

head -c10 file_name 顯示一開始的10個字節(jié)

head -c-10 file_name 顯示除末尾10個字節(jié)之外的內(nèi)容

head -n10 file_name 顯示一開始的10行內(nèi)容

head -n-10 file_name 顯示除末尾的10行之外的內(nèi)容

Usage: head [OPTION]... [FILE]...
Print the first 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
 -c, --bytes=[-]NUM    print the first NUM bytes of each file;
               with the leading '-', print all but the last
               NUM bytes of each file
 -n, --lines=[-]NUM    print the first NUM lines instead of the first 10;
               with the leading '-', print all but the last
               NUM lines of each file
 -q, --quiet, --silent  never print headers giving file names
 -v, --verbose      always print headers giving file names
 -z, --zero-terminated  line delimiter is NUL, not newline
   --help   display this help and exit
   --version output version information and exit

NUM may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: http://www.gnu.org/software/coreutils/head

tail命令及其選項如下:

tail -c10 file_name 顯示末尾的10個字節(jié)

tail -c-10 file_name 顯示除開頭10個字節(jié)之外的內(nèi)容

tail -n10 file_name 顯示末尾的10行內(nèi)容

tail -n-10 file_name 顯示除開頭的10行之外的內(nèi)容

Usage: tail [OPTION]... [FILE]...
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.

With no FILE, or when FILE is -, read standard input.

Mandatory arguments to long options are mandatory for short options too.
 -c, --bytes=[+]NUM    output the last NUM bytes; or use -c +NUM to
               output starting with byte NUM of each file
 -f, --follow[={name|descriptor}]
              output appended data as the file grows;
               an absent option argument means 'descriptor'
 -F            same as --follow=name --retry
 -n, --lines=[+]NUM    output the last NUM lines, instead of the last 10;
               or use -n +NUM to output starting with line NUM
   --max-unchanged-stats=N
              with --follow=name, reopen a FILE which has not
               changed size after N (default 5) iterations
               to see if it has been unlinked or renamed
               (this is the usual case of rotated log files);
               with inotify, this option is rarely useful
   --pid=PID      with -f, terminate after process ID, PID dies
 -q, --quiet, --silent  never output headers giving file names
   --retry       keep trying to open a file if it is inaccessible
 -s, --sleep-interval=N  with -f, sleep for approximately N seconds
               (default 1.0) between iterations;
               with inotify and --pid=P, check process P at
               least once every N seconds
 -v, --verbose      always output headers giving file names
 -z, --zero-terminated  line delimiter is NUL, not newline
   --help   display this help and exit
   --version output version information and exit

NUM may have a multiplier suffix:
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

With --follow (-f), tail defaults to following the file descriptor, which
means that even if a tail'ed file is renamed, tail will continue to track
its end. This default behavior is not desirable when you really want to
track the actual name of the file, not the file descriptor (e.g., log
rotation). Use --follow=name in that case. That causes tail to track the
named file in a way that accommodates renaming, removal and creation.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: http://www.gnu.org/software/coreutils/tail

搭配管道使用更佳

此外,這三個命令常常與管道功能搭配,用于文件內(nèi)容的操作,例如:

對data.txt中的數(shù)據(jù)進行排序:cat data.txt | sort

對data.txt中的內(nèi)容匹配:cat data.txt | grep 'a'

輸出data.txt中的非空行數(shù):cat -b data.txt | wc -l

總結(jié)

到此這篇關(guān)于Linux文本查看命令及其選項詳解(cat,head,tail)的文章就介紹到這了,更多相關(guān)Linux文本查看命令及其選項內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 關(guān)于SSH 遠程執(zhí)行命令你要知道的二三事

    關(guān)于SSH 遠程執(zhí)行命令你要知道的二三事

    SSH 是 Linux 下進行遠程連接的基本工具,但是如果僅僅用它來登錄那可是太浪費啦!SSH 命令可是完成遠程操作的神器啊,下面這篇文章主要給大家介紹了關(guān)于SSH 遠程執(zhí)行命令的一些相關(guān)資料,需要的朋友可以參考下。
    2017-07-07
  • Shell腳本經(jīng)典之Fork炸彈的分析與預(yù)防

    Shell腳本經(jīng)典之Fork炸彈的分析與預(yù)防

    這篇文章主要給大家介紹了Shell腳本經(jīng)典之Fork炸彈的分析與預(yù)防,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。
    2017-06-06
  • 一個Linux系統(tǒng)安全設(shè)置的Shell腳本的分享(適用CentOS)

    一個Linux系統(tǒng)安全設(shè)置的Shell腳本的分享(適用CentOS)

    這篇文章主要介紹了一個設(shè)置Linux系統(tǒng)安全的Shell腳本的分享,適用CentOS,包含大部份的安全設(shè)置,只需執(zhí)行腳本就可以得到一個相對安全的Linux系統(tǒng)了,需要的朋友可以參考下
    2014-06-06
  • Linux Shell中三種引號的用法及區(qū)別

    Linux Shell中三種引號的用法及區(qū)別

    Linux Shell中有三種引號,分別為雙引號(" ")、單引號(' ')以及反引號(` `)。那么這三種引號有什么區(qū)別呢?下面腳本之家小編給大家介紹下用法及區(qū)別,需要的的朋友參考下
    2017-03-03
  • 在shell腳本中激活conda虛擬環(huán)境的方法總結(jié)

    在shell腳本中激活conda虛擬環(huán)境的方法總結(jié)

    在Anaconda中conda可以理解為一個工具,也是一個可執(zhí)行命令,其核心功能是包管理與環(huán)境管理,下面這篇文章主要給大家介紹了關(guān)于如何在shell腳本中激活conda虛擬環(huán)境的相關(guān)資料,需要的朋友可以參考下
    2022-08-08
  • linux上配置jdk時,java命令提示沒有此文件或文件夾的解決方法

    linux上配置jdk時,java命令提示沒有此文件或文件夾的解決方法

    下面小編就為大家?guī)硪黄猯inux上配置jdk時,java命令提示沒有此文件或文件夾的解決方法。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-05-05
  • shell腳本通過expect實現(xiàn)自動單邊無密登錄功能

    shell腳本通過expect實現(xiàn)自動單邊無密登錄功能

    最近做項目需要實現(xiàn)單邊無密登錄功能,接下來小編給大家分享shell腳本通過expect實現(xiàn)自動單邊無密登錄功能,一起看看吧
    2017-01-01
  • 利用shell腳本進行批量處理文件后綴名

    利用shell腳本進行批量處理文件后綴名

    這篇文章主要給大家介紹了關(guān)于如何使用shell腳本進行批量處理文件后綴名,文中通過實例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2023-12-12
  • shell遞歸輸出文件名和目錄名的方法

    shell遞歸輸出文件名和目錄名的方法

    今天小編就為大家分享一篇shell遞歸輸出文件名和目錄名的方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-06-06
  • npm script命令同時進行多個監(jiān)聽服務(wù)的方法

    npm script命令同時進行多個監(jiān)聽服務(wù)的方法

    這篇文章主要介紹了npm script命令同時進行多個監(jiān)聽服務(wù)的方法,非常不錯,具有一定的參考借鑒價值,需要的朋友參考下吧
    2018-08-08

最新評論