0

I have a document with 1+ million of the following strings and I like to create some new structures byextract some parts and create a csv file for it, what's the quickest way to do this?

document/0006-291X(85)91157-X

I would like to have a file with on each line the original string and the extracted parts

document/0006-291X(85)91157-X;0006-291X;85 
1
  • What exactly do you want to extract? And what have you tried so far? Commented Nov 20, 2013 at 11:00

1 Answer 1

6

You can try this one-liner awk:

awk -F "[/()]" -v OFS=';' '{print $0,$(NF-2),$(NF-1)}' your-file

It parses the fields of each line with taking /,(,) as delimiters. Then it prints out the whole line, the 3rd field and the second field starting from the end of the line. The option -v OFS=';' prints semicolumns as output field separator.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks Bentoy13 that's very cool stuff which I didn't think off and works perfectly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.