I have a CSV file about covid19 and I need to pass the first column to a row delimited by ";", which I have to print on the Shell screen.
Each value cannot be repeated but I have already achieved this, I just need to transpose.
I put the code that I have done so far:
cat covid19.csv | sort | cut -d "," -f1 | uniq
I have seen that sed and awk could be used to transpose but I am not allowed to do so. I have to manage to find another way. I thought I might as well use a for loop for this since I saw it on a forum but for now I can't do it like that.
You were fine with
cut
to get the first column. Now it's about putting all the lines together and this can be done bytr
translating (tr
adducting) one character into another; in this case, the semicolon line break:You can put the part
uniq
behindcut
if you need it.Example:
Note that there is always an
;
ending, since the last line also has a line break.