Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

how to split a column values into separate columns?

I have a txt file details.txt like this

name class school

a 1 sec

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

b 2 pri

c 3 hrsec

I want the values separated by space as diffenent columns.
so column 1 should be
name

a

b

c

column 2 should be
class

1

2

3

By the end I want the file to be a .csv file.

I used

awk -F " " ‘OFS="\t" {print $1,$2,$3 > ("output.csv")}’ details.txt

When I open the output file in excel all the values are in the same column. Please help with this. I am new to this. Thanks.

>Solution :

Use , (for the CSV(

awk -vOFS=, '{print $1,$2,$3}' details.txt > output.csv

and Excel would take the columns

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading