Split a file in to multiple files
If we have a file with 1-300 lines are there & need to create separate files for 20 lines... means need to create 15 files to separate the 20 lines in each file.
mkdir test
cd test
split -l 20 ../server.txt
bash-3.2$ ls -l
total 128
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaa
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xab
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xac
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xad
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xae
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaf
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xag
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xah
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xai
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaj
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xak
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xal
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xam
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xan
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xao
mkdir test
cd test
split -l 20 ../server.txt
bash-3.2$ ls -l
total 128
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaa
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xab
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xac
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xad
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xae
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaf
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xag
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xah
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xai
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xaj
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xak
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xal
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xam
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xan
-rw-r--r-- 1 davsingh staff 500 Jan 10 15:21 xao
Comments
Post a Comment