Working with files and directories under HP-UX

Source: Internet
Author: User
Tags command line valid

Create a file

You can use the Cat command to create a file that contains text. For example, to create a file named "MyFile," use the Cat command as follows:

$ cat > MyFile

After you type this command, the cursor is in the first line of the empty file. Type the text and press the Enter key at the end of each line. To exit the file, press D while holding down the CTRL key. The cat command returns you to the command line prompt.

You can use the Cat command to create your own version of MyFile. For example, you can create the following files:

$ cat > Myfilethe text I am typing is stored in "myfile". Enteri Press RETURN to the end of the Enterwhen i ' m finished, I hold down the CTRL key and press D. enterctrl-d

Enumerating files

To verify that cat has created myfile, run the LS command, which lists the file name. Running the LS command at the same time and the file name confirms that the file exists but does not list other files.

LS (1)

$ ls myfile

The myfile ls command lists the myfile.

To view additional information about the file, use the LL (long listing) command.

LL (1)

$ ll MyFile

-rw-r--r--1 myname mygroup 146 August 4 14:13 myfile

The mysterious character (-rw-r--r--) at the beginning of the previous line represents the permissions of the owner, group users, and other users to read and/or write files. "1" indicates the number of links (names) associated with this file, "myname" usually refers to the login name, "MyGroup" is the name specified by the administrator, which belongs to the group of users working with you, and "146" is the number of bytes (characters) of the file, followed by the date when the file was last modified, and the file name.

naming files

When you select a file name, the name length and the character type that you include need to follow specific rules.

Guidelines for naming files

When choosing a filename, keep the following rules in mind:

Typically, a file name can contain up to 256 characters (for non-ASCII character sets, 256 bytes). These characters can be in any of the following combinations:

Uppercase or lowercase letters (A to Z;a to Z)

Number (0 to 9)

Special characters, such as: + 、-、 _ and.

According to the above rules, the following file name is a valid name:

Valid name

Money acct.01.87 Code.clost+found 112.3-data Foo_bar

File names in HP-UX are case-sensitive. Therefore, all of the following file names are different:

Money, money, money

Remarks: Short file name System:

On some computers, the file name cannot be longer than 14 characters in length. If you are unsure if the computer you are using can support a longer file name, check with your system administrator. Alternatively, you can try to create a file with a longer name to see if the file name will be truncated.

Hide file name

The first character is the file name of Point (.) that is a hidden file name because the LS command does not display the file name correctly. If you do not want or need to display some files while running LS, use a hidden file name.

For example, when you log on, the system runs a hidden boot file, a login script (for customizing the work environment). For more information about logon scripts, see "Setting up the system environment using logon Scripts" in chapter 3rd, "Using the Shell".

To enable LS to list hidden file names, including the name of the logon script, run the command and-a option at the same time:

$ ls-a Use-A to view hidden file names.

. Profile MyFile This is the POSIX Shell, so show. Profile.

Hidden files or "dot files" are typically used to store configuration information. If you are not sure what the file is intended for, do not delete it.

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.