zoukankan      html  css  js  c++  java
  • Linux shell basic2 cat find tr

    Cat stands for concatenate.

    Case 1.

    When the text files have more blank lines, we want to remove them.

    We can use regex s+ ' '.

    cat file.txt | tr s ' '

    cat -T file.txt # show tabs as ^.

    cat -n file.txt # show line numbers

    . Specifies current directory and .. Specifies the parent directory. This convention is followed throughout the Unix file system.

       

    find . -iname "*.txt"

    i means ignore the case.

    find . ( -name "*.txt" -o -name "*.pdf" ) -print

    ./text.pdf

    ./new.txt

    find . -iregex ".*(.py|.sh)$"

    ./test.py

    ./new.PY

    find . ! -name "*.txt" -print

    Files not end with .txt.

    find . -maxdepth 1 -type f -print

    Just show file and not traverse the sub folder.

    find . -type d

    Just show the directory

    Type :

    f : file

    d: directory

    l: link

    Print all the files that were accessed within the last 7 days as follows:

    $ find . -type f -atime -7 -print

    atime: access time

    mtime: modify time

    -ctime:change time

    n order to print all the files that are having access time older than seven minutes, use the

    following command:

    $ find . -type f -amin +7 -print

    For example, find all the files that are having a modification time greater than that of the

    modification time of a given file.txtfile as follows:

    $ find . -type f -newer file.txt -print

    Search based on file size

    Based on the file sizes of the files, a search can be performed as follows:

    $ find . -type f -size +2k

    # Files having size greater than 2 kilobytes

    Instead of kwe can use different size units as the following:

    b– 512 byte blocks

    c– bytes

    w– two byte words

    k– Kilobyte

    M– Megabyte

    G– Gigabyte

    find . -type f -name "*.c" -exec cat {} ;>all_c_files.txt

    $ cat example.txt # Example file

    1 2 3 4 5 6

    7 8 9 10

    11 12

    $ cat example.txt | xargs

    1 2 3 4 5 6 7 8 9 10 11 12

    $ cat example.txt | xargs -n 3

    1 2 3

    4 5 6

    7 8 9

    10 11 12

    echo "hello linux" | tr 'a-z' 'A-Z'

    HELLO LINUX

    echo "Hello 123 world 456" | tr -d '0-9'

    Hello world

    echo hello 1 char 2 next 4 | tr -d -c '0-9 '

    1 2 4

    echo "I am your friends?" | tr -s ' '

    I am your friends?

    find -type f | xargs md5sum

    e8bc686b2c380b9ad56c024a03384150 ./sub/java.txt

    a5bf231497e5d503172bfd39a387b197 ./all_txt_files.txt

    e827b6437257f24b9e5fbba44fd98f5c ./num.txt

    b6d9275e7e16b154059677fac91baa79 ./test.txt

    b6d9275e7e16b154059677fac91baa79 ./mul_bank.txt

    sort -r : sort in reverse order

    Split can used to split file to specify size.

    Looking for a job working at Home about MSBI
  • 相关阅读:
    Java动态代理详解
    (10) openssl dhparam(密钥交换)
    (9) openssl enc(对称加密)
    (8) openssl rsautl(签名/验证签名/加解密文件)和openssl pkeyutl(文件的非对称加密)
    (7) openssl dgst(生成和验证数字签名)
    (6) openssl passwd(生成加密的密码)
    (5) openssl speed(测试算法性能)和openssl rand(生成随机数)
    (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)
    (3) openssl genrsa(生成rsa私钥)
    (2) OpenSSL命令
  • 原文地址:https://www.cnblogs.com/huaxiaoyao/p/4293493.html
Copyright © 2011-2022 走看看