I have a file with dates as
'2013-01-01'
'2013-01-02'
I want the output to be
'2013-01-01','2013-01-02'
if there is only 1 entry then there should not be any comma.
I have a file with dates as
'2013-01-01'
'2013-01-02'
I want the output to be
'2013-01-01','2013-01-02'
if there is only 1 entry then there should not be any comma.
Try:
perl -0ne '$,=",";print split /\n/;print "\n"' file
i cannot be using perl command
Try :
$ awk '{printf "%s%s",NR==1 ? "" : OFS,$0}END{printf RS}' OFS=, file
'2013-01-01','2013-01-02'
---------- Post updated at 02:24 AM ---------- Previous update was at 02:00 AM ----------
OR
$ tr -s '\n' ',' <file | sed 's/,$/\n/g'
paste -sd, - <infile
I think it could be made even shorter:
paste -sd, infile
cat Sample | tr "\n" ","