Salved by bash again

I was willing to create a incremental Patch numeration:

Original:
Patch :0001-ENGR00090813-1-merge-imx-2.6.24-2.3.0-to-2.6.26.patch
Patch :0002-ENGR00090813-2-Porting-changes-for-2.6.26.patch
Patch :0003-ENGR00090813-3-mx51-Add-core-mach-support.patch
Patch :0004-ENGR00086937-mxc_i2c-remove-unneeded-spinlock-and-p.patch
Patch :0005-ENGR00070687-1-ipuv3-add-serial-interface-support.patch
Patch :0006-ENGR00070687-2-mx51-add-ipu-and-lcd-support.patch
Patch :0007-ENGR00086541-mc13892-remove-debug-info-of-pmic-adc.patch

Result:
Patch1 :0001-ENGR00090813-1-merge-imx-2.6.24-2.3.0-to-2.6.26.patch
Patch2 :0002-ENGR00090813-2-Porting-changes-for-2.6.26.patch
Patch3 :0003-ENGR00090813-3-mx51-Add-core-mach-support.patch
Patch4 :0004-ENGR00086937-mxc_i2c-remove-unneeded-spinlock-and-p.patch
Patch5 :0005-ENGR00070687-1-ipuv3-add-serial-interface-support.patch
Patch6 :0006-ENGR00070687-2-mx51-add-ipu-and-lcd-support.patch
Patch7 :0007-ENGR00086541-mc13892-remove-debug-info-of-pmic-adc.patch

$ i=0; while read line; do i=$(($i + 1)); echo $line | sed “s/Patch0/Patch$i/” >> result_file; done < original_file

Thanks Rogerio for suggestion using "while read".

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s