15 Linux Split and Join Command Examples to Manage Large Fil
$ ls -lart x* So we see that no zero sized chunk was produced in the above output. 7. Customize Number of Lines using -l optionNumber of lines per output split file can be customized using the -l option. As seen in the example below,split files are created with 20000 lines. $ split -l20000 split.zip Get Detailed Information using –verbose optionTo get a diagnostic message each time a new split file is opened,use –verbose option as shown below. $ split -l20000 --verbose split.zip creating file `xaa' creating file `xab' creating file `xac' Linux Join Command Examples8. Basic Join ExampleJoin command works on first field of the two files (supplied as input) by matching the first fields. Here is an example : $ cat testfile1 1 India 2 US 3 Ireland 4 UK 5 Canada So we see that a file containing countries was joined with another file containing capitals on the basis of first field. 9. Join works on Sorted ListIf any of the two files supplied to join command is not sorted then it shows up a warning in output and that particular entry is not joined. In this example,since the input file is not sorted,it will display a warning/error message. $ cat testfile1 1 India 2 US 3 Ireland 5 Canada 4 UK 10. Ignore Case using -i optionWhen comparing fields,the difference in case can be ignored using -i option as shown below. $ cat testfile1 a India b US c Ireland d UK e Canada 11. Verify that Input is Sorted using –check-order optionHere is an example. Since testfile1 was unsorted towards the end so an error was produced in the output. $ cat testfile1 a India b US c Ireland d UK f Australia e Canada 12. Do not Check the Sortness using –nocheck-order optionThis is the opposite of the previous example. No check for sortness is done in this example,and it will not display any error message. $ join --nocheck-order testfile1 testfile2 a India NewDelhi b US Washington c Ireland Dublin d UK London 13. Print Unpairable Lines using -a optionIf both the input files cannot be mapped one to one then through -a[FILENUM] option we can have those lines that cannot be paired while comparing. FILENUM is the file number (1 or 2). In the following example,we see that using -a1 produced the last line in testfile1 (marked as bold below) which had no pair in testfile2. $ cat testfile1 a India b US c Ireland d UK e Canada f Australia 14. Print Only Unpaired Lines using -v optionIn the above example both paired and unpaired lines were produced in the output. But,if only unpaired output is desired then use -v option as shown below. $ join -v1 testfile1 testfile2 f Australia 15. Join Based on Different Columns from Both Files using -1 and -2 optionBy default the first columns in both the files is used for comparing before joining. You can change this behavior using -1 and -2 option. (编辑:武汉站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |