Skip to main content
2 of 2
added 2 characters in body
Wildcard
  • 37.5k
  • 30
  • 149
  • 284

Just use ex, the POSIX-specified scriptable form of vi (which is also POSIX-specified).

printf '%s\n' '/pattern/-r !awk "NR>3" somefile' x | ex receivingFile

Or more generally:

printf '%s\n' '/pattern/-r !somecommand' x | ex somefile
Wildcard
  • 37.5k
  • 30
  • 149
  • 284