I have a file containing the next lines:
copy THIS:0022 to UNB:0022;
copy THIS:0023 to UNB:0023;
copy THIS:0024 to UNB:0024;
I would like to process each line and create an if statement around it, like:
if THIS:0022 != ""
copy THIS:0022 to UNB:0022;
endif
if THIS:0023 != ""
copy THIS:0023 to UNB:0023;
endif
if THIS:0024 != ""
copy THIS:0024 to UNB:0024;
endif
How can this be done using bash and awk (and/or sed)?
Put it in
foo.sh
and run./foo.sh < infile
.