bash string manipulation

Hello guys,

here is my problem:

I got a shell script which is called by an external piece of software, the external software is not under my control. The software passes data as an argument to my script like

./bla.sh 'service;1234567890;ok;hostname;some text here'

I need to pass the data to another piece of software but I need to manipulate the string first.

I need the data to change to this:

service;1234567890;ok;hostname;"some text here"

I tried various seds, IFS & reads but nothing worked...

Can someone of you guys help please?

Greeting
Snoogie

OLDIFS="$IFS" ; IFS=";"
        set -- $1
IFS="$OLDIFS"

echo "$1;$2;$3;$4;\"$5\""
1 Like

Here is another way

#!/bin/bash

out=`echo $1 |awk -F";" '{printf("%s;%s;%s;%s;\"%s\"\n",$1,$2,$3,$4,$5)}'`
echo "$out"
1 Like

Works perfectly, thanks guys!