I am trying to come up with a bash script to remove parts of a file name on CentOS. My file names are:
119903_Relinked_new_3075_FileNote_07_02_2009_JHughes_loaMeetingAndSupport_FN_205.doc
119904_relinked_new_2206_Support_Intensity_Scale_SYCH_SIS_264549.pdf
119905_relinked_new_3075_Consent_07_06_2009_DSweet_CRFA_CF_16532.docx
29908_relinked_new_2206_Assessor_Summary_Report_SERT_I_OTH_264551.pdf
009712_relinked_new_3075_Consent_07_06_2009_CWell_DPRT_check_CF_16535.pdf
I would like to remove 119903_Relinked_new_
from the file names. The end result should be:
3075_FileNote_07_02_2009_JHughes_loaMeetingAndSupport_FN_205.doc
2206_Support_Intensity_Scale_SYCH_SIS_264549.pdf
3075_Consent_07_06_2009_DSweet_CRFA_CF_16532.docx
2206_Assessor_Summary_Report_SERT_I_OTH_264551.pdf
3075_Consent_07_06_2009_CWell_DPRT_check_CF_16535.pdf
I have been trying multiple scripts but coming up short. The number before _Relinked_new_
is different in most cases and the file extensions vary across .pdf
, .docx
, .doc
etc. Any help would be appreciated.
relinked
can be eitherr
orR
, is that right? – terdon Apr 18 '22 at 15:42