1

I have a csv file

abc,ds,adsa
bca,sds,ds
cdf,ds,sds
abk,sds,ds

I want this file to be split in two files only where one should have all values of first column valuestart with "ab", and rest in other file. My final output should be

file1.csv as

abc,ds,adsa
abk,sds,ds

file2.csv as

bca,sds,ds
cdf,ds,sds

Timely help will be highly appreciated.

Matthieu
  • 2,736
  • 4
  • 57
  • 87
Prem
  • 11
  • 2

1 Answers1

0

You can use grep to filter your file:

cat full.csv | grep ^ab > file1.csv
cat full.csv | grep -v ^ab > file2.csv

First line says that show only lines that begins with 'ab' and second line use (-v) to inverse result

Joan Esteban
  • 1,006
  • 12
  • 23