I have three variables I write into a text file. For now it is into a variable, because try and error is faster like this. These three variables are produced by the script before and each variable has a column with values in them. Variable one for example looks like this:
hour
minute
minute
day
I put them together using this code:
New_fileloc=$(paste <(echo "$Grabinterval") <(echo "$Filelocation") <(echo "$Time") --delimiters ';' | sed -e 's/^\|$/"/g' -e 's/\;/";"/')
At the end I need each line in each column in double quotes and separated by a semicolon. At the moment I am doing that using sed in that one liner. And that works mostly fine. My output looks like this:
"hour";"A_path/to/somewhere/;2016-02-10 17:07:00Z"
"minute";"A_path/to/somewhere/;2016-01-29 17:26:20Z"
"minute";"A_path/to/somewhere/;2016-01-29 17:26:20Z"
"day";"A_path/to/somewhere/;2016-01-29 00:07:00Z"
The first semicolon gets replaces with ";", but the second one in each line does not. I have no idea why.
In your last command to sed you are missing a g
s/\;/";"/g
Your original command with 's/\;/";"/' will only make one replacement, the first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With