Extract from a large file and save it to another file.
Source: Internet
Author: User
Save the extracted part of a large file to another file-Linux Enterprise Application-Linux server application information. For more information, see the following. Problem:
There is a 3G text, which needs to be processed. Each test consumes too much resources. Therefore, code testing should be performed on a small scale. The common practice is to extract a part from the original text, such as the first 100 rows.
Solution:
You can use the head command in linux to easily solve the problem and use pipelines. The Code is as follows: head filename-n 100> newfile
Note:
It is easy to think that the first 100 rows are taken. If the last 100 rows are taken, you can use tail. The combination of head and tail can also take any part of the file. The following are examples:
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