Hello,
I would like to split a file but I dont what the subfiles to be named the way they are:
ex:
default name: xaa xab xac xad xae
desired name: b01 b02 b03 b04 b05
I know I can rename them afterwards however I have a varialbe split lenghth, in other words I am not sure how many subfiles I will have.
That is up to the user of the script.
I am using an if statement for renaming these but it makes my script really long and I can never catch all the possibilites since there are infinit number of subfiles the user might want.
This is what I am doing (not very smart):
If ( `echo $NumofSub` == 2 ) then
mv xaa b01.txt
mv xab b02.txt
else if ( ..... so forth
I hope I am clear enough, but if not please let me know if you have any
questions. I am using tcsh by the way I know I shouldnt but my whole script is in tcsh, cant change it now.
Have learnd my lesson and will most likely use bash for my next script.
---------- Post updated 11-13-11 at 01:02 AM ---------- Previous update was 11-12-11 at 11:52 PM ----------
if any one is interested, I wrote this which works :).
#!/bin/tcsh
#batch rename
split -l 40 260_sites.txt
@ bnum = 1
foreach batch ( `ls | grep xa` )
mv $batch b0"$bnum".txt
@ bnum = $bnum + 1
end