I am writing a shell script where I am reading all the files in a directory, performing some criteria checks and splitting certain files on number of records (lines)I want to split file abc.txt as abc(AA or 01).txt(I don't mind anything as long as it begins with abc and ends in .txt)Is there a simple way to do this ?I am using split command:split -l $line_count $file $????   I am confused what should be in place of ????I am open to other methods too but I would prefer to just change the ??? as the other parts of the script is ready.Many Thanks  
naming split files using split command
shell script;shell
Try:split -l 5 --additional-suffix=.txt abc.txt abcOr, if you want numbers in place of letters:split -l 5 -d --additional-suffix=.txt abc.txt abcThe abc that we added after the file names serves as the prefix.Because you wanted .txt as a suffix, we added the option --additional-suffix=.txt.The optional -d tells split to use numbers instead of letters.ExampleLet's start with a directory with one file:$ lsabc.txtNow, let's split that file:$ split -l 5 -d --additional-suffix=.txt abc.txt abc$ lsabc00.txt  abc01.txt  abc02.txt  abc03.txt  abc.txtWork-around 1: using shellCurrent versions of GNU split support the --additional-suffix option and split is part of GNU coreutils.  That means that this option will be eventually be available on all linux systems.For systems that currently lack it, one work around is to rename the files after split creates them.  For example:$ split -l 5 -d abc.txt abc$ for f in ./abc??; do mv $f $f.txt; done$ lsabc00.txt  abc01.txt  abc02.txt  abc03.txt  abc.txtThe above assumes that the default suffix length of 2 applies.  If not, change the number of ? to match the suffix length that you are using.  For example, if you are using a suffix length of 5:$ split -l 5 -a 5 -d abc.txt abc$ for f in ./abc?????; do mv $f $f.txt; done$ lsabc00000.txt  abc00001.txt  abc00002.txt  abc00003.txt  abc.txtWork-around 2: using awkHere, the option l specifies the number of lines to include in each splitted file and d specifies the number of digits to use in the splitted files name.  Make sure that d is large enough.$ awk -v l=5 -v d=2 '{n=0000 int((NR-1)/l); f=abc substr(n,length(n)+1-d) .txt; if (f!=old) close(old); old=f; print >f}' abc.txt$ lsabc00.txt  abc01.txt  abc02.txt  abc03.txt  abc.txt