Shell Script to modify a text file for SQL usage -
i have text file process. sample input:
'edmonton event', '2013-11-16-14.00.00', 'ww', 'ww', 'keeper' 'edmonton event', '2013-11-16-14.00.00', 'ww', 'aw', 'seeker' 'edmonton event', '2013-11-16-14.00.00', 'ww', 'iw', 'left beater' 'edmonton event', '2013-11-16-14.00.00', 'ww', 'sw', 'right beater'
can tell me how add { ....... },
@ both ends of each line using shell script?
sample output:
{'edmonton event', '2013-11-16-14.00.00', 'ww', 'ww', 'keeper'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'aw', 'seeker'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'iw', 'left beater'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'sw', 'right beater'},
you can use sed
regular expression put whole line matching group, replace surrounding curly braces , comma @ end.
sed 's/\(.*\)/{\1},/g' input.txt > output.txt
without redirecting output get:
> sed 's/\(.*\)/{\1},/g' input.txt {'edmonton event', '2013-11-16-14.00.00', 'ww', 'ww', 'keeper'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'aw', 'seeker'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'iw', 'left beater'}, {'edmonton event', '2013-11-16-14.00.00', 'ww', 'sw', 'right beater'},
Comments
Post a Comment