0

I have a file (tsm) as below :

V1                                                        V2

Library Name:                                            abc

DriveName:                                               123

Device Type:                                              xyz

WWN:              567

Library Name: feg

DriveName:    124

Device Type:    wef

WWN:   312

I want to get an output with only the drive name followed by wwn.

I have tried , but I get a <0 rows> (or 0-length row.names) message.

> tsm[grep("DriveName | WWN",tsm$V1,fixed = TRUE) , ]
[1] V1 V2
<0 rows> (or 0-length row.names)
3
  • What is the expected output? If you need the rows with either DriveName or WWN Try grep("^(DriveName|WWN)", tsm$V1) Commented Mar 15, 2016 at 7:54
  • How about removing the space in "DriveName | WWN" or the argument fixed = TRUE? Commented Mar 15, 2016 at 7:55
  • yes removing the space and fixed =true also worked , thanks ! Commented Mar 15, 2016 at 8:03

2 Answers 2

1

We can try

tsm[grep("^(DriveName|WWN)", tsm$V1),]
Sign up to request clarification or add additional context in comments.

Comments

0

I've come across the solution, thanks for the assistance !

tsm[grep(c("WWN|DriveName"),tsm$V1), ]

Comments

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.