Reputation: 649
I have a big file name lef_list with data in below format:
$PRJ/fp/t/std/tcb/libs/tcb.lb.gz \
$PRJ/mm/T/v/mem_gen/ram/NLDM/ram.lib \
I want to read each line of file and split the lines into two based on pattern '/libs/' or '/NLDM/' in line and replace those with word '/LEF/' and write in a new file.
The output should be like :
$PRJ/fp/t/std/tcb/lef/tcb.lb.gz \
$PRJ/mm/T/v/mem_gen/ram/LEF/ram.lib \
I tried the below code:
while IFS="/libs/" read -r line val
do
echo "$line"/LEF/"$val";
done < lef_list
This code shows error as while expression syntax. command not found.
Someone please suggest any solution.
Upvotes: 1
Views: 50
Reputation: 786291
A simple sed
should do the job:
sed -E 's~/(libs|NLDM)/~/LEF/~g' file
$PRJ_WORK_DIR/foundationip/tsmc/tsmc_lvt_stdcells/tcbn16ffcllbwp16p90cpdlvt/LEF/ccs/tcbn16ffcllbwp16p90cpdlvtssgnp0p72vm40c_hm_ccs.lib.gz \
$PRJ_WORK_DIR/mem/tech/TSMC_16FFC/v37/mem_gen/data_new/ram_dp_ulvt_pg_rd_64x44_mux4/LEF/ram_dp_ulvt_pg_rd_64x44_mux4_ssgnp0p72vm40c.lib \
Pattern /(libs|NLDM)/
matches /libs/
or /NLDM/
and replaces that with /LEF/
.
Or if you have to use awk
only then:
awk '{gsub(/\/(libs|NLDM)\//, "/LEF/")} 1' file
Upvotes: 1