Linux shell basic3 dd wc comm chmod ls

來源:互聯網
上載者:User

標籤:

Generating files of any size

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

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:

[[email protected] test]$ cat file1.txt file2.txt

1

2

3

4

1

2

4

5

[[email protected] test]$ comm file1.txt file2.txt

1

2

3

4

5

[[email protected] test]$ comm file1.txt file2.txt -1

1

2

4

5

[[email protected] test]$ comm file1.txt file2.txt -2

1

2

3

4

[[email protected] test]$ comm file1.txt file2.txt -3

3

5

[[email protected] 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

[[email protected] 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.

Linux shell basic3 dd wc comm chmod ls

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.