Sort by file splitting and merging

Source: Internet
Author: User

Python code # output sorted result sort-o result. out video.txt # split the fields by ': 'sort-t:-r video.txt # test whether it has been sorted sort-c video.txt # sort by 2nd field sort-t: + 1 video.txt # sort 3rd field using ascii order sort-t: + 2 video.txt sort-t:-k3 video.txt # sort 3rd field using number order sort-t: + 2n video.txt sort-t:-k3n video.txt # uniq sort-u video.txt # sort 4th field, then sort 1st field sort-t: -k4-k1 video.txt # sort + field_number.characters_in # sort 2nd filed, ining with 3rd character sort-t: + 1.2 video.txt # list all unix users cat/etc/passwd | sort-t: + 0 | awk-F ":" '{print $1}' # only not duplicate. here, sort is recommendable sort video.txt | uniq-u # only duplicate sort video.txt | uniq-d # count dulicate times sort video.txt | uniq-c # join, the files must have a common content; the fields must be splited by single tab or space join [options] input-file1 input-file2-an n, the number of files. -a1, means joining files based on file 1-o n. m n, the number of file; m, the number of field. -o 1.3, means display field 3 of file 1-jn m n, the number of file; m, the number of field. -t delimiter # join cross join names.txt town.txt # mismatch connections, join all join-a1-a2 names.txt town.txt # base on file1, join all join-a1 names.txt town.txt # selective join-o 1.1, 2.2 names.txt town.txt # different field join # extract 3rd field of file 1, 2nd field of file 2, then join them together join-j1 3-j2 2 file1 file2 cat pers P. jones Office Runner ID897 S. round UNIX admin ID666 L. clip Personl Chief ID982 cat pers2 Dept2C ID897 6 years Dept3S ID666 2 years Dept5Z ID982 1 year join-j1 4-j2 2 pers2 ID897 P. jones Office Runner Dept2C 6 years ID666 S. round UNIX admin Dept3S 2 years ID982 L. clip Personl Chief Dept5Z 1 year # cut [options] file1 file2-c LIST, select only these characters-f LIST, select only these fields-d, delimiter cut-d: -f4 pers cut-d:-f1, 3 pers cut-d:-f1-3 pers cut-d:-f1, 6/etc/passwd # file permision ls-l | cut-c1-10 # paste-d-s-file1 file2-d, delimiter-s, paste one file at a time instead of in parallel paste-d: pas1 pas2 # list file name, 3 files each row ls | paste-d ""---# list file name, ls-l | awk 'nf> 3 {print $8} 'ls | paste-d ""-# split-output_file_size input-filename output-filename-output_file_size, default 1000 lines output-filename, default x [aa]-> x [zz]

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.