![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Need help with awk - how to read a content of a file from every file from file list | tanit | Shell Programming and Scripting | 7 | 03-10-2009 05:19 AM |
| file size comparision local file and remote file | dba.admin2008 | Shell Programming and Scripting | 4 | 11-13-2008 05:57 PM |
| PDF Splitter & Merger: 3.0 released | iBot | Software Releases - RSS News | 0 | 11-04-2008 06:00 PM |
| Reading file names from a file and executing the relative file from shell script | anushilrai | Shell Programming and Scripting | 4 | 03-10-2006 05:25 AM |
| file splitter | ECBROWN | UNIX for Dummies Questions & Answers | 0 | 09-28-2005 03:17 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
File splitter by nth row
I need to split a file into n separate files of about the same size. The way the file will be split is at every nth row, starting with the first row, that row will be cut and copied to it's corresponding new file so that each file has unique records. Any 'leftovers' will go into the last file. e.g.
Code:
>ls sample.txt > cat sample.txt aab aac aad aae aaf aag aah aai aaj aak aal aam Desired output: Code:
>ls -l sample.txt sample1.txt sample2.txt sample3.txt sample4.txt >cat sample1.txt aab aae aai aam >cat sample2.txt aac aag aal >cat sample3.txt aad aaj >cat sample4.txt aaf aah aak Thanks in advance. |
|
||||
|
Thanks Danmero. This works perfectly. If you could unpack this part of the Awk statement for my learning benfit, that would be extremely helpful and appreciated.
Code:
c=(NR%n)?c:0} |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|