Is this hard to do?
Answer: that depends on the person, the language used, etc.
Any ideas what this script would look like?
Answer: Yes.
I am however afraid that your next question will be: Can you give me that same look? So here it is:
#!/bin/bash
while read TYPE EQSIGN RESTOFLINE
do case ${TYPE} in
ACCESSORID)
ACC="${RESTOFLINE%% *}"
;;
PROFILES)
for PROFILE in ${RESTOFLINE}
do echo "${ACC} ${PROFILE}"
done
;;
esac
done <data
It supposes that your input file is in the same dirctory and has the name “data” (look at the last line of the sript where you can change this). I copied your input to make *data *and when I run it I get:
lcomars wrote:
> I have a file that I need to clean up and reformat and I thought maybe I
> could right a script for this. Below is what the data looks like:
>
> ACCESSORID = UFLSCLC NAME = TOM JONES
> PROFILES = PHVPWTR2
>
>
>
> ACCESSORID = UFLSDAM NAME = MIKE JONES
> PROFILES = PHVPWTR2
>
>
>
> ACCESSORID = UFLSDNM NAME = BOB SMITH
> PROFILES = PXMDWTAM PHVPWTR5 PHVPBOS7
>
> PROFILES = PHVPWTBC PHVPBOS8
>
>
>
> ACCESSORID = UFLSEAL NAME = TOM SMITH
> PROFILES = PHVPWTR2
>
> The output that I need is this:
>
> UFLSCLC PHVPWTR2
> UFLSDAM PHVPWTR2
> UFLSDMN PXMDWTAM
> UFLSDMN PHVPWTR5
> UFLSDMN PHVPBOS7
> UHVPDMN PHVPWTBC
> UHVPDMN PHVPBOS8
> UFLSEAL PHVPWTR2
>
> Is this hard to do? Any ideas what this script would look like?
>
> Thanks!
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org