zoukankan      html  css  js  c++  java
  • Linux shell basic3 dd wc comm chmod ls

    Generating files of any size

    /dev/zerois a character special device, which infinitely returns the zero byte ().

    The above command will create a file called junk.datathat is exactly 1MB in size. Let's go

    through the parameters: ifstands for – inputfile, ofstands for – outputfile, bsstands for

    BYTES for a block, and countstands for the number of blocks of bsspecified to be copied.

    dd if=/dev/zero of=junk.data bs=1M count=1

    1+0 records in

    1+0 records out

    1048576 bytes (1.0 MB) copied, 0.00263553 s, 398 MB/s

    Comm command demo:

    [hadoop@namenode test]$ cat file1.txt file2.txt

    1

    2

    3

    4

    1

    2

    4

    5

    [hadoop@namenode test]$ comm file1.txt file2.txt

    1

    2

    3

    4

    5

    [hadoop@namenode test]$ comm file1.txt file2.txt -1

    1

    2

    4

    5

    [hadoop@namenode test]$ comm file1.txt file2.txt -2

    1

    2

    3

    4

    [hadoop@namenode test]$ comm file1.txt file2.txt -3

    3

    5

    [hadoop@namenode test]$ comm file1.txt file2.txt -3 -1

    5

    -1 removes first column from output

    -2 removes the second column

    -3 removes the third column

    [hadoop@namenode test]$ ll

    total 1052

    -rw-rw-r--. 1 hadoop hadoop 99 Feb 16 08:34 all_txt_files.txt

    -rw-rw-r--. 1 hadoop hadoop 8 Feb 17 03:29 file1.txt

    -rw-rw-r--. 1 hadoop hadoop 8 Feb 17 03:29 file2.txt

    -rw-rw-r--. 1 hadoop hadoop 1048576 Feb 17 03:20 junk.data

    -rw-rw-r--. 1 hadoop hadoop 44 Feb 16 02:06 mul_bank.txt

    -rw-rw-r--. 1 hadoop hadoop 30 Feb 16 08:55 num.txt

    drwxrwxr-x. 2 hadoop hadoop 4096 Feb 16 03:05 sub

    -rw-rw-r--. 1 hadoop hadoop 44 Feb 16 02:11 test.txt

    "-"—if it is a regular file.

    "d"—if it is a directory

    "c"—for a character device

    "b"—for a block device

    "l"—if it is a symbolic link

    "s"—for a socket

    "p"—for a pipe

    chmod u=rwx g=rw o=r filename

    Here:

    u =specifies user permissions

    g =specifies group permissions

    o =specifies others permissions

    chmod a+x filename

    a statnd for all.

    Read,write,and execute permissions have unique octal numbers as follows:

    r--=4

    -w-=2

    --x=1

    Touch is a command that can create blank files or modify the timestamp of files if they

    already exist.

    Symbolic links are just pointers to other files.

    ln -s targetfilename(directory) link_name

    ln -s test.txt test_link.txt

    Counting number of lines, words, and characters in a file

    $ wc -l file # count number of lines as follows:

    $ wc -w file #count words number

    $ head -10 filename

    $ tail -10 filename

    Head used to get the first n lines of the file.

    Tail is used to get the last n lines of the file.

    Looking for a job working at Home about MSBI
  • 相关阅读:
    CF954I Yet Another String Matching Problem ( FFT )
    P4173 残缺的字符串 (带通配符的FFT字符匹配)
    电灯泡(简单容斥)
    HDU 6143 Killer Names (容斥)
    bzoj 3597: [Scoi2014]方伯伯运椰子[分数规划]
    【COGS2652】秘术「天文密葬法」(长链剖分,分数规划)
    Longge's problem ( gcd的积性)
    Desert King POJ
    P3628 [APIO2010]特别行动队(斜率dp)
    树状数组
  • 原文地址:https://www.cnblogs.com/huaxiaoyao/p/4293983.html
Copyright © 2011-2022 走看看