0

Hello I'm Try read two patterns in a file in only line

example:

bla bla bla pattern 1 with space content content content pattern 2 with space bla bla bla

I'm tried used

cat file.asc | awk '/pattern 1 with space/,/pattern 2 with space/'  > test.txt

but don't work

I need save two patterns test.txt:

content
content
content
Fabian Feriks
  • 47
  • 4
  • 8

2 Answers2

0

same line pattern match needs another approach

$ echo "bla bla bla pattern 1 with space content content content pattern 2 with space bla bla bla" |
  sed -E 's/.*pattern 1 with space (.*) pattern 2 with space .*/\1/;s/ /\n/g'

content content content

karakfa
  • 66,216
  • 7
  • 41
  • 56
0

You mean something like this?

#!/bin/bash
text="bla bla bla pattern 1 with space content content content pattern 2 with space bla bla bla"
echo "$text" | sed 's/.*pattern 1 with space \(.*\)pattern 2 with space.*/\1/;s/ /\n/g'

output

content
content
content
UtLox
  • 3,744
  • 2
  • 10
  • 13