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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -