jeudi 3 mars 2016

Extract a specific pattern of string from each row and create another column with Linux script

I have a few rows, for example:

andrew cnp1253 richard
maria-cnp543-1 jfsbdfs
cnp4321, jfbd

I want to have a second column with only the cnp's:

cnp1253
cnp543-1
cnp4321

I know I should use the wildcards and replace whichever it is outside, but if for example I use cnp, I don't know how to also keep the digits.

I tried this with Excel, but I would like to create a script for it.

Thanks, Olivia

Aucun commentaire:

Enregistrer un commentaire