Quick tip: split a large file into smaller files

26 October, 2007 – 4:22 pm

Needed to break a large file containing many messages, each message separated on a new line into many new small files containing only one message per file … Started thinking in perl, but almost looked past the Unix split command:

split -l 1 -a 3 bigfile.txt smallfile_

-l ‘n’ will put ‘n’ lines per file
-a ‘n’ defines the length of the suffix, in this case 3 letters

QED

Share it: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netscape
  • Reddit
  • Slashdot
  • Technorati
  • YahooMyWeb

Post a Comment

*
To prove that you're not a bot, enter this code
Anti-Spam Image