Hi all,
I have a moderate size (300 lines) BASH Shell script that performs various tasks on different source reports (CSV files). One of the tasks that it performs, is to use SED to replace 'non-conforming' titles with conformant ones. For example "How to format a RAW Report" needs to become "how_to_format_a_raw_report".
Right now, I include the SED commands within the BASH script. However, new titles are added almost daily, and we don't want any Joe (no offense to all the Joes out there..) going into the BASH script to add new SED commands.
I do have a delimited file that contains just two columns; SourceTitle:::OutputTitle (with ::: as the delimiter).
What would be the best way to incorporate a command (say SED, or AWK, or any other common-use command that doesn't need to be installed separately) to read each line of the delimited text file to get its information?
This is what the delimited text file looks like (titles.text):
SourceTitle:::OutputTitle
This is a non-conforming title:::this_title_now_conforms
This_title_no_so_bad:::this_title_is_not_so_bad
How to format reports:::how_to_format_reports
Formatting source reports:::formatting_source_reports
This is what the actual source report the BASH script works upon (source.csv):
Date,Title,Views,Source
21-05-16,ProdA,This is a non-conforming title,487,YouTube
26-05-16,ProdA,This_title_no_so_bad,38,YouTube
14-06-16,ProdB,How to format reports,83,YouTube
22-06-16,ProdC,Formatting source reports,129,Internal
I can't unfortunately, include the BASH script here, but suffice it to say, if I had an idea of how to include a command that would step out and read the titles.text file and make the changes to source.csv, I'd be set.
Rich
P.S. At first glance the titles look like you can simply apply commands such as tr, sed, etc. to perform tasks such as 'replace whitespace with underscore', 'change all to lowercase', etc. but it isn't the case. Each title is evaluated on an individual basis to determine what the output will be. This is how the titles.text is generated.
P.P.S. The environment is Cygwin & Solaris using BASH, and AIX 7.1 using KSH. The Cygwin/Solaris environment is a must; the AIX is gravy..