bash - csplit prefix as file context -
i wrote bash script in order split file. file looks this:
@<tripos>molecule zinc32514653 .... .... @<tripos>molecule zinc982347645 .... ....
here script wrote:
#!/bin/bash #split file files named xx##.mol2 csplit -b %d.mol2 ./zincpharmer_ligprep_1.mol2 '/@<tripos>molecule/' '{*}' #rename files called xx##.mol2 2nd line zinc###### filename in ./xx*.mol2; newfilename=$(echo $filename | sed -n 2p $filename) if [ ! -e "./$newfilename.mol2" ]; mv -i $filename ./$newfilename.mol2 else num=2 while [ -e "./"$newfilename"_$num.mol2" ]; num=$((num+1)) done mv $filename "./"$newfilename"_$num.mol2" fi done
i have 2 questions:
1) there way include prefix option csplit , telling csplit prefix line after seperator.
2) first line created csplit xx00 empty file, separator in first line. how can avoid this?
the expected output files named zinc32514653.mol2 , zinc982347645.mol2. in case there 2 entries same zinc### zinc982347645_2.mol2.
all need know if available man csplit
page:-
to tell csplit
change prefix:-
-f, --prefix=prefix use prefix instead of 'xx'
to exclude empty files:-
-z, --elide-empty-files remove empty output files
Comments
Post a Comment