日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

liunx 分割合并文件

發布時間:2025/4/5 35 豆豆
生活随笔 收集整理的這篇文章主要介紹了 liunx 分割合并文件 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


dd的作用是轉換和拷貝文件,我們可以利用它來分割文件,相關的選項如下:

if=filename:輸入的文件名

of=finename:輸出的文件名

bs=bytes:一次讀寫的字節數,默認是512bytes

skip=blocks:拷貝前,跳過的輸入文件的前blocks塊,塊的大小有bs決定

count=blocks:只拷貝輸入文件的前blocks塊?

例如,現在有一個文件file,大小為116616字節:

  • [root]#?du?-b?file??

  • 116616??file??

  • 將其分割為兩文件file1和file2,那我們就設置每塊為1024字節,將file的前60塊放入file1,余下的放入file2:

  • [root]#?dd?if=file?bs=1024?count=60?skip=0??of=file1??

  • [root]#?dd?if=file?bs=1024?count=60?skip=60?of=file2??

  • 然后用cat將兩個文件合并為file.bak,要注意文件的順序:

  • [root]#?cat?file1?file2?>?file.bak??

  • 可以用md5sum驗證一下file和file.bak:

  • [root]#?md5sum?file??

  • 3ff53f7c30421ace632eefff36148a70??file??

  • [root]#?md5sum?file.bak??

  • 3ff53f7c30421ace632eefff36148a70??file.bak??

  • 可以證明兩個文件時完全相同的。


    grep手冊中的解釋:

    Context Line Control

    -A NUM, --after-context=NUM
    ? ?Print NUM ?lines ?of ?trailing ?context ?after ?matching ?lines.
    ? ?Places ? a ?line ?containing ?a ?group ?separator ?(--) ?between
    ? ?contiguous groups of matches. ?With the ?-o ?or ?--only-matching
    ? ?option, this has no effect and a warning is given.

    -B NUM, --before-context=NUM
    ? ?Print ?NUM ?lines ?of ?leading ?context ?before ?matching lines.
    ? ?Places ?a ?line ?containing ?a ?group ?separator ?(--) ? between
    ? ?contiguous ?groups ?of ?matches. ?With the -o or --only-matching
    ? ?option, this has no effect and a warning is given.

    -C NUM, -NUM, --context=NUM
    ? ?Print NUM lines of output context. ?Places a line ?containing ?a
    ? ?group separator (--) between contiguous groups of matches. ?With
    ? ?the -o or --only-matching option, ?this ?has ?no ?effect ?and ?a
    ? ?warning is given.

    簡單翻譯就是,-A -B -C 后面都跟阿拉伯數字,-A是顯示匹配后和它后面的n行。-B是顯示匹配行和它前面的n行。-C是匹配行和它前后各n行。總體來說,-C覆蓋面最大。用它保險些。哈哈。這3個開關都是關于匹配行的上下文的(context)。

    于是,

    ??grep?-A?4?wikipedia?密碼文件.txt

    grep -A 100000 "/pic/" t_pic_queue



    轉載于:https://blog.51cto.com/jueshizhanhun/1740683

    《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀

    總結

    以上是生活随笔為你收集整理的liunx 分割合并文件的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。