One-liners: Difference between revisions
just catting around |
Adds example on how to split large files |
||
Line 47: | Line 47: | ||
<ref>https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands</ref> | <ref>https://stackoverflow.com/questions/5119946/find-exec-with-multiple-commands</ref> | ||
== Split a big file == | |||
Say you have a file with 50,000 lines in it, which becomes unwieldy to deal with in a spreadsheet or otherwise. You can easily split the file into segments with the <code>split</code> command. Be default it uses alpha suffixes (little_file.aa, little_file.ab, etc.) If you add the option <code>--numeric-suffixes</code>, then you'll end up with little_file.00, little_file.01, etc. If you would like to re-add the original suffix, then you must use the option called <code>--additional-suffix</code> | |||
The following command takes BIG_FILE.txt and for every 10,000 lines of that file, it generates new files called 'little_file.00.txt', 'little_file.01.txt', 'little_file.02.txt', and so on. | |||
<source lang="bash"> | |||
split --lines=10000 --numeric-suffixes --additional-suffix='.txt' BIG_FILE.txt little_file. | |||
</source> | |||
{{References}} | {{References}} | ||
[[Category:Bash]] | [[Category:Bash]] | ||
[[Category:System Administration]] | [[Category:System Administration]] | ||
[[Category:Files]] |