Oracle technology: Use of CUT commands in Linux

Source: Internet
Author: User
Tags min range split stdin oracle database linux

Cut can extract a portion of the desired extract from each row of file (or stdin or pipe) Extract selected fields of a file.

Usage

Cut-blist [-n] [file]

cut-clist [File]

cut-flist [-ddelim] [-S] [--output-delimiter=string] [file]

LIST

The list is a location that needs to be extracted using integers (in ascending order):

Enumerate list:

Use, (comma) or blank-character;

Range Range:

Use-represents.

More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/database/Oracle/

For example: 1,4,7,1-3,8, or omit representation: -5,10 (equivalent to 1-5,10), 3-(equivalent to 3-end).

File

The pathname of the file to extract, or, if not specified or used, to accept the data from stdin.

1. Extract Cut-blist [-n] [file] in bytes byte

A. For example: Cut-b1-5 means to extract the 1th to 5th bytes of each row;

Complete Example: echo "This is min" | Cut-b1-6 return this I

B. Cut-blist-n:-N and-B use to prevent multi-byte multibyte characters from being cut;

2. Extract cut-clist by character [file]

For example: Echo "This is min" | Cut-c1-6, return this I

3. After the Split field field extraction

cut-flist [-ddelim] [-S] [--output-delimiter=string] [file]

The procedure is to split the string of each line according to the delimiter specified by-ddelim (by default, tab), and then return the contents of the specified field according to the value of the list.

For example:

echo "This is min" | cut-f1,3 returns this min, splits according to the default tab, returns the result or according to tab.

echo "This_is_min" | cut-f1,3-d "_" back to This_min, according to the specified _ to split, return the result using _ split.

For rows that do not have a Delim full return, you can use-s if you do not want to return;

The fields returned by default are still shown in the Delim partition specified by-D, and can be specified using--output-delimiter=string if you want the specified delimiter to be used in the result.

For example: Echo "This_is_min" | cut-f1,3-d "_"--output-delimiter= "-" Returns the result is This-min

Application Examples:

1, there is a page of phone number thin file Contacts.txt, the above in order to write the rules of the "People's names, home address, telephone, remark," and so on, if used;

If you want to extract the names of everyone and their corresponding phone numbers, use the command:

Cat Contacts.txt | cut-f1,3-d ";"

2, to see the Linux under the current all users:

cat/etc/passwd | cut-f1,3-d ":"

The second column is greater than 500 for the user created, and less than 500 for the system-defined user.

For example:

###################################################################

# # Ckinstance.ksh # #

###################################################################

echo "' Date '"

echo "Oracle Database (s) Status ' hostname '"

Namelst= ' Ps-ef|grep ora_pmon|grep-v Grep|awk ' {print $} ' |cut-c10-15 '

For name in $namelst

Todo

If [-Z $name];then

echo "Oracle instance-$name: Down"

Else

echo "Oracle instance-$name: Up"

Fi

Author: 51cto Oracle small-mixed son

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.