Skip to main content
2 of 5
added 243 characters in body
jai_s
  • 1.5k
  • 7
  • 7

sed is clumsy, but here is what I could get -

sed  's/.*\(Apple\)[^:]*:"\([0-9]*\)".*/Enter product ID: \1\nYour  product ID is: \2/' 3
Enter product ID: Apple
Your product ID is: 2134

sed  's/.*\(Mango\)[^:]*:"\([0-9]*\)".*/Enter product ID: \1\nYour product ID is: \2/' 3
Enter product ID: Mango
Your product ID is: 4567

explanation : substitute the string Mango : with -> Your product ID is: Mango Your product ID is : \1 and \2 save the matched expression in (..) for later use.

jai_s
  • 1.5k
  • 7
  • 7