• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            posts - 297,  comments - 15,  trackbacks - 0
            1.關(guān)于文件對比的Scripts
            diff -b -r $Dir1 $Dir2 | grep -v "Common subdirectories" | grep -e "^diff" -e "^Binary files" -e "^Only"
            diff:
             -b  --ignore-space-change 
                          Ignore changes in the amount of white space.
             -r  --recursive
                          Recursively compare any subdirectories found.
            grep:
             -v, --invert-match
                          Invert the sense of matching, to select non-matching lines.
             -e PATTERN, --regexp=PATTERN
                          Use PATTERN as the pattern; useful to protect patterns beginning with -.

            2. grep的正則表達(dá)式:
            比如,要匹配兩個單詞:  word  exec
            grep -E "word|execl"  是可以得到正確結(jié)果的
            AND:
            grep -E "word&execl"  和預(yù)期的不一樣
            grep -E 'excel.*word|work.*excel'是可以的。
            注:正則表達(dá)式跟邏輯操作符是倆概念 , 只有awk支持||,&&這樣的操作,
            用grep的話, 也只支持|而不支持&。
            正則基礎(chǔ):)
            $cat rfile
            abcd
            abc
            ab
            $grep -E 'abc.*' rfile
            abcd
            abc
            $grep -E 'abc*' rfile
            abcd
            abc
            ab

            3. 如何獲得一個文件的前N列或是其中的幾列?
            cut -f-2 -d ' ' filename
            -f field   -d dilimeter

            4.刪除某個目錄下不是以.sh .h .c結(jié)尾的文件
            find . -type f | awk '!/\.sh$/ && !/\.[c|h]$/{print $1}' | xargs rm

            5.原來用冒號分隔的,選出幾列來,改成用豎杠分隔的
            cat /etc/passwd | awk -F: '{print $1"|"$2"|"$3"|"$4}'

            6.去掉文件中的字符,比如去掉從win上傳到Linux上的文件時會有個^M,若去掉他可以用:
            tr -d '\015'  < filename

            7.目錄樹是
            A/B/C/
            A/B/C/ccc/...
            A/B/C/bbb/...
            A/B/C/D/aaa/...
            我現(xiàn)在在A下,我要查找html后綴文件, 但是不想它在包含aaa||bbb||ccc的目錄下查找.
            find . \( -name Input -o -name Output -o -name Current \) -type d -prune -o -name "*.htm" -print
            這個命令中的目錄排除沒有起作用,為什么嗯?很困惑。
            find . -wholename './A/B' -prune -o -print
            這個命令也不起作用,更困惑了,不認(rèn)wholename

            8. 循環(huán)讀文件的命令
            for x in `seq 1 12`; do cat $x|awk '{print $9}' && sleep 3;done
            seq 是Linux 中一個預(yù)設(shè)的外部命令,一般用作一堆數(shù)字的簡化寫法,如
            seq 1 10
            便會出現(xiàn)
            1
            2
            3
            4
            5
            6
            7
            8
            9
            10
            它還有三個選項(xiàng)
              -f, --format=FORMAT      use printf style floating-point FORMAT (default: %g)
              -s, --separator=STRING   use STRING to separate numbers (default: \n)
              -w, --equal-width        equalize width by padding with leading zeroes
            -f 最常用 , 例如一次制做 10 個名 dir001 , dir002 .. dir010 的目錄,它便很有用途,我們可以這樣
            下一個命令便可了
            seq -f 'dir%03g' 1 10 | xargs mkdir

            mkdir $(seq -f 'dir%03g' 1 10)
            它用的是 printf 的格式 , %03g' 代表以三位浮點(diǎn)數(shù),以此方法,
            如用bash3 的 printf也可作為等價命令
            printf 'dir%03d\n' {1..10} | xargs mkdir  或 mkdir `printf 'dir%03d ' {1..10}`
            awk 當(dāng)然也可以
            awk 'BEGIN { while (num < 10 ) printf "dir%03d\n", ++num ; exit}' | xargs mkdir
            這樣會比寫一個腳本快, 不必寫成
            for dir in 001 002 003 004 005 006 007 008 009 010
            do
                mkdir dir${dir}
            done

            9.找出當(dāng)前目錄下大于100M的目錄
            find . -maxdepth 1 -type d | xargs du -sh | grep -v '\.$'| grep -P '^\S+M\t' | awk -FM '$1>1'

            posted on 2009-11-08 11:19 chatler 閱讀(257) 評論(0)  編輯 收藏 引用 所屬分類: Shell
            <2009年11月>
            25262728293031
            1234567
            891011121314
            15161718192021
            22232425262728
            293012345

            常用鏈接

            留言簿(10)

            隨筆分類(307)

            隨筆檔案(297)

            algorithm

            Books_Free_Online

            C++

            database

            Linux

            Linux shell

            linux socket

            misce

            • cloudward
            • 感覺這個博客還是不錯,雖然做的東西和我不大相關(guān),覺得看看還是有好處的

            network

            OSS

            • Google Android
            • Android is a software stack for mobile devices that includes an operating system, middleware and key applications. This early look at the Android SDK provides the tools and APIs necessary to begin developing applications on the Android platform using the Java programming language.
            • os161 file list

            overall

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            午夜精品久久影院蜜桃| 久久婷婷五月综合97色直播| 久久w5ww成w人免费| 久久99国产精品尤物| 99久久99久久| 综合久久一区二区三区 | 久久夜色撩人精品国产| 性做久久久久久久久老女人| 国产人久久人人人人爽| 深夜久久AAAAA级毛片免费看| 亚洲AV无码久久寂寞少妇| 中文字幕一区二区三区久久网站 | 久久ww精品w免费人成| 青青草国产97免久久费观看| 国产成人久久精品一区二区三区| 久久综合久久伊人| 99久久国产综合精品成人影院| 区久久AAA片69亚洲| 久久精品国产亚洲av瑜伽| 精品熟女少妇a∨免费久久| 国产精品中文久久久久久久| 国产亚洲精午夜久久久久久| 精品久久久久久国产91| 亚洲成色www久久网站夜月| 久久久久99这里有精品10| 91精品国产91久久久久久蜜臀| 久久精品九九亚洲精品| 精品伊人久久久| 亚洲午夜久久久| 人妻少妇精品久久| 久久亚洲av无码精品浪潮| 久久男人AV资源网站| 国产精品伊人久久伊人电影| 天天爽天天爽天天片a久久网| 伊人久久精品无码二区麻豆| 精品久久久中文字幕人妻| 国产一区二区久久久| 精品多毛少妇人妻AV免费久久| 少妇被又大又粗又爽毛片久久黑人| 久久久久人妻一区精品| 人妻无码精品久久亚瑟影视|