Hi.
If I have a txt file in the following format:
option1=123
option2=abc
option3=321
How do I convert it with KSH into the following format (with the additional prefixed string):
${filename},::option1=123,option2=abc,option3=321
Many thanks
Hi.
If I have a txt file in the following format:
option1=123
option2=abc
option3=321
How do I convert it with KSH into the following format (with the additional prefixed string):
${filename},::option1=123,option2=abc,option3=321
Many thanks
What have you tried so far?
Is the filename the value or the literal string as shown?
There are various ways to do this, so it would be good to know how you have tried/how you think so that it is supportable in future.
Kind regards,
Robin
Hi. I've tried the following and it seems to work. But maybe there's a better or more efficient way of doing this.
#!/bin/ksh
typeset filename=dummyfile
typeset NEWLINE="${filename},::"
typeset PARAM_LIST=$(cat a.b)
set -A PLIST $PARAM_LIST
for PARAM in ${PLIST[@]}
do
NEWLINE="${NEWLINE}"${PARAM}","
done
#drop the last ","
RES=${NEWLINE%?}
print "${RES}"
exit 0
Hi.
The utility paste
:
paste -d, - - - < your-file-name
produces
option1=123,option2=abc,option3=321
Bes wishes ... cheers, drl