28. Several common Linux Shell functions, split

Source: Internet
Author: User

1. Description

Split [-BL] File prefix

2. Option

Parameters:

-B: the size of the file to be split. The unit can be added, for example, B, K, and M;

-L: split by the number of rows.

Prefix: indicates the meaning of the prefix. It can be used to separate the prefix Text of the case.

3. Example

1) Split-B 30B Prime. cpp me

2) Split-l 20 Prime. cpp

3) Cat XA *> Prime. cpp // in this way, use redirection to combine separated files.

4) ll-k xa *

-K like -- block-size = 1 K

5) ls-al./| split-B 200b-Hello

-It will be treated as stdin or stdout.

3. Split in awk

Awk's built-in function split can split strings into words and save them in an array.

Format: Split (string, array, field separator)

1) name = "76868 & 5676 & 435 & 43526 & 334 & 12312312 & 12321"

Awk 'in in {print split ('"\" $ name \ ""', filearray ,"&")}'

Note: awk requires that system variables must be referenced using single quotation marks and double quotation marks, that is, the format of '"$ sysvar"', but the split function also needs double quotation marks to define, but this double quotation mark cannot be explained by SH, but should be left to awk for explanation. Therefore, double quotation marks consisting of \ "and \" are used.

2) awk 'in in {print split ("76868 & 5676 & 435 & 43526 & 334 & 12312312 & 12321", filearray ,"&")}'

Reference

[1] laruence's private dish

Http://linux.vbird.org/linux_basic/0320bash.php#split

[2]Http://www.kklinux.com/html/biancheng/Shell/200901/24-2793.html

[3] split in awk

Http://blog.sina.com.cn/s/blog_4d1f40c00100r7y3.html

Http://zhu8337797.blog.163.com/blog/static/1706175492010113051014526/

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.