Unix shell programming (1)

Source: Internet
Author: User

Unix shell programming (1)

Unix only recognizes three basic file types: common files, directory files, and special files.
Normal file: any file on the system that contains data, test, program instructions, or just about anything else.

Number of words in the Statistical File: WC command
For example:
[Root @ localhost test] # WC makefile
22 84 600 makefile
The first digit indicates the number of rows contained in the makefile, the second digit indicates the number of words contained in the file, and the third digit indicates the number of characters contained in the file.
Command parameters:
-L indicates the number of lines displayed
-C indicates the number of characters displayed.
-W indicates the number of words displayed.

Display working directory: PWD command
For example:
[Root @ localhost test] # pwd
/Tools/test

LS command details:
[Root @ localhost test] # ls-l
Total 44
Drwxrwxrwx 8 1000 1000 4096 make-3.81
-RW-r -- 1 Root 600 makefile
-RW-r -- 1 Root 364 makefile2
-Rwxrwxr-x 1 Root 4995 test_endian
-RW-r -- 1 Root 215 test_endian.c
------
The first line indicates the number of storage space occupied by the file.
The subsequent lines show the details of each file in the directory.

Link file: ln command
Command Format: ln from
It is similar to a shortcut on Windows.
For example:
Ln ABC writeback
Ls-l
Display:
Total 48
-RW-r -- 2 root Root 13 ABC
-RW-r -- 1 Root 6 collect
-RW-r -- 1 Root 6 mon
-RW-r -- 1 Root 6 WB
-RW-r -- 1 Root 6 wbx
-RW-r -- 2 root Root 13 writeback
Note: Number 2 indicates that the number of links is 2, which means that a file can be linked multiple times.
Run:
[Root @ localhost programs] RM ABC
RM: Remove regular file 'abc '? Y
[Root @ localhost programs] # ls
Collect mon WB wbx writeback
[Root @ localhost programs] # ls-l
Total 40
-RW-r -- 1 Root 6 collect
-RW-r -- 1 Root 6 mon
-RW-r -- 1 Root 6 WB
-RW-r -- 1 Root 6 wbx
-RW-r -- 1 Root 13 writeback
----------------
The number of links to the writeback file is changed to 1; the file still exists, so it is different from the shortcut on the Windows platform.
The most common purpose of LN is to link files in different directories.
The only restriction on linked files is that the linked files must coexist in the same file system.
To link to files in different file systems, you can add the-s option to the ln command to create a symbolic link.

 

The symbolic link is different from the initial link: the symbolic link points to the initial file. If the initial file is deleted, the symbolic link does not work.
For example:
[Root @ localhost programs] # ln-s WB WBB
[Root @ localhost programs] # ls-l
Total 44
-RW-r -- 1 Root 6 collect
-RW-r -- 1 Root 6 mon
-RW-r -- 1 Root 6 WB
Lrwxrwxrwx 1 Root 2 WBB-> WB
-RW-r -- 1 Root 6 wbx
-RW-r -- 1 Root 13 writeback
Note: The WBB file type is 1, indicating that it is a symbolic link.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.