This script will be useful if you require to split a huge file based on number of lines or records. Normal file splitters available in the market split the file based on the size (byte, KB, MB) which cannot be used to split based on number of lines or records.
Steps to use the script:
- Save the below script as lsplit.ksh
"Cut here from $startLineNo to $endLineNo"
p $inpFile > $inpFile.
$count + 1`
- Create a properties file SSNRange.txt.prop which would contain the range of records or lines. Example of properties file is as follows
- Run the script1
$ lsplit.ksh infile.txt
- Three output files will be created
- infile.txt.split.1 –> Creates a file with first 400 lines
- infile.txt.split.2 –> Creates a file with lines starting from 401 to 1504
- infile.txt.split.3 –> Creates a file with lines starting from 1505 to 7000
- File is split based on line numbers are records.
- No manual editing is required the correct the first and last records
- Easy to handle it in batch