Create different files from input file.

I have file A.txt

File A

1,Hi,234
2,Hello,345
1,Kal,980,
9,KJ,098
2,de,098
..
...

I have more then 600 lines...

I want separate the files as per 150 line.

First 150 lines ----File A1.xtx
Second 150 lines ---File A2.txt
Third 150 lines----File A3.txt.
...
Rest of ----File N.txt.
..

Thanks

split -d -l 150 inputfile A

Other than the names you specified for the output files, a very simple way to do what you're asking for is:

split -l 150 A

It will split A into files each of which (except the last will contain 150 lines) and name them Aaa, Aab, ..., Aaz, Aba, ...

If you need more than 676 or will never need more than 26 output files, you can add a [-a suffix_length] option to specify the number of characters in the suffix that will be generated. But there is no way to produce decimal digits instead of base 26 encoding supplied by using the lowercase alpha characters, and there is no way to put the suffix in the middle of the generated filenames (such as Acc.txt).

-d ?

True. Not with split anyway.

Note that the -d option isn't specified by the POSIX/UNIX standards and is not available on many systems.

1 Like