Newbie ? : Sed vs Awk: Best Way To Filter a Pattern Match From String?


Results 1 to 2 of 2

Thread: Newbie ? : Sed vs Awk: Best Way To Filter a Pattern Match From String?

  1. #1
    Join Date
    Jan 2022
    Posts
    1

    Question Newbie ? : Sed vs Awk: Best Way To Filter a Pattern Match From String?

    I'm new to bash, and still uncertain when/how to use sed vs awk.

    I'm trying to assign all pattern matches in a string to a variable, and then filter them from a string.

    Here's the pattern:

    [space]*[space][space]* # 2 spaces and any character afterward until the next space.

    Or if at the start of string:
    *[space]

    Example:
    raw_string='test1 this is test2 string'

    I want: test1, test2 assigned to variables. And then filter the string to match, 'this is a string'.

    What is the right way to do this in bash?

    Thanks

  2. #2
    Join Date
    Feb 2014
    Location
    Riviera Beach, Maryland, USA
    Posts
    172

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •