I need to replace spaces with comma and then remove certain extra specific chars from a string.
echo "$d"
>>Mon Apr 22 05:06:00 UTC 2019
jent=$(echo $jt1 | sed 's/[[:space:]]/,/g')
echo "$jent"
>>Mon,Apr,22,05:06:00,UTC,2019 #this does the first job of replacing the space with comma
But again I want to remove the UTC part and the comma before it, how can I achieve it?
desired output should be
Mon,Apr,22,05:06:00,2019
You can do it with one sed call, e.g.
$ echo "Mon Apr 22 05:06:00 UTC 2019" | sed 's/ \(UTC \)\?/,/g'
Mon,Apr,22,05:06:00,2019
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments