I have bunch of CSV files named like so in a directory:
s_m_u_supplemental_fields_account_9_4_2015_11_26_Error.csv
s_m_u_supplemental_fields_account_9_4_2015_12_3_Error.csv
s_m_u_academic_status_loa_8_29_2015_0_1_Error.csv
I need to capture the "s_m_u_academic_status_loa" part to append to a column inside the file. I tested the expression "s/^\(s_([^_0-9]+_)+\)\([^\.]+\.csv\)$/\1/"
in RegEx Tester online and does capture what I need, but for some reason it fails to work from AIX ksh.
Here is my script so far (AIX 6.2):
#!/bin/ksh
ls *_Error.csv | while read i
do
echo ${i}
edfilename = `echo ${i} |sed -e "s/^\(s_([^_0-9]+_)+\)\([^\.]+\.csv\)$/\1/"`
echo ${edfilename}
done
echo "$edfilename"
instead of justecho $edfilename
. – roaima Sep 7 '15 at 19:16