New answers tagged split
1
This wasn't available back then but with more recent versions of split one can use:
--additional-suffix=SUFFIX
append an additional SUFFIX to file names.
so adding
--additional-suffix=.txt
to the command means the resulting files will automatically have .txt extension.
split -dl 10000 --additional-suffix=.txt words wrd
4
Unless I'm missing something, split does split by line if you use -l switch:
-l, --lines=NUMBER
put NUMBER lines per output file
so
split -l 1 inputfile
should do what you want.
2
awk '{print > $0".txt" }' inputfile
would create one file per unique line in inputfile named after the content of those lines (with a .txt extension). But beware that when the limit of concurrent open files is reached, some awk implementations will fail.
Or
awk '{f = "output_file." NR; print $0 > f; close(f)}' inputfile
To have numbered output ...
3
A=0
while IFS= read -r LINE ; do
printf '%s\n' "$LINE" > newfile$A
(( A++ ))
done < "$INPUTFILE"
Top 50 recent answers are included