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
  • 相关阅读:
    js监听对象属性的改变
    js中的垃圾回收机制
    防抖和节流
    Ajax的浏览器缓存问题及解决方法
    Java多线程系列---“基础篇”07之 线程休眠
    Java多线程系列---“基础篇”06之 线程让步
    Java多线程系列---“基础篇”05之 线程等待与唤醒
    Java多线程系列---“基础篇”04之 synchronized关键字
    Java多线程系列---“基础篇”03之 Thread中start()和run()的区别
    Java多线程系列---“基础篇”02之 常用的实现多线程的两种方式
  • 原文地址:https://www.cnblogs.com/huaxiaoyao/p/4293493.html
Copyright © 2011-2022 走看看