1

I am looking to separate these two columns, each into their own separate text files. This data is from a csv file on Kaggle that contains Titanic passenger data. The first column is the number of passengers, and the second column is the age of those passengers I.e. 10 one year olds, 12 two year olds, etc . I want to separate these and put them into a simple graph in the command line.I have used csvkit so far to manipulate the data set. Thanks! I am new to Linux and this is my first dabble into tapping into the community!

 10 1
 12 2
  7 3
 10 4
  5 5
  6 6
  4 7
  6 8
 10 9
  4 10

1 Answers1

0

Many different ways to achieve this, but cut is likely the easiest.

cut -f1 -d" " inputfile >column1.txt

cut -f2 -d" " inputfile >column2.txt

steve
  • 21,582
  • 5
  • 48
  • 75
  • 1
    Thank you Steve! Though I can't seem to get that to work. Does it matter that there are multiple spaces before the first column? If so, is there a simple way to snap everything to the beginning of the text file? – Tyler Young May 08 '21 at 21:28
  • Ahh, in that case try `awk '{ print $1 }' inputfile >column1.txt` – steve May 08 '21 at 21:46
  • 1
    Thanks so much Steve that did the trick! My first awk use-case! – Tyler Young May 08 '21 at 22:17