1

I have a plain text file with many lines, I am trying to get only the lines that start with |V| and runtime

What I have tried:

sed -e '/^\(runtime\|\\|V\\|\)/p' test.txt > test.out.txt
sed -e '/^(runtime\|\\|V\\|)/' test.txt > test.out.txt
sed -e '/^runtime/p' -e '/^\\|V\\|/p' test.txt > test.out.txt
sed -i.bak '/^\\|V\\|\|runtime/!d' test.txt
sed -i.bak '/^(\\|V\\|\|runtime)/!d' test.txt
pcregrep -M '^(runtime|\|V\|)*' test.txt > test.out.txt
egrep '^(runtime|\|V\|)*' test.txt > test.out.txt

Nothing works. I will either get an empty file or the same file duplicated.

Drew
  • 1,171
  • 4
  • 21
  • 36

1 Answers1

1

Like this? First some test data:

$ cat foo
|V|
runtime
foo

then the greṕ command:

$ grep "^\(|V|\|runtime\)" foo
|V|
runtime
James Brown
  • 36,089
  • 7
  • 43
  • 59
  • 1
    That worked, which seems odd, cause I thought I tried that and it did not before... Well, at least its solved. – Drew Mar 08 '18 at 01:43