Issue
I want all digits after a equal sign in a given string to be replaced with the text 'NULL'. I am new to using sed. How do I get the desired output using sed?
Input: /getProduct?productId=1234&quanity=4
Output: /getProduct?productId=NULL&quantity=NULL
Example 2:
Input: /getCustomers?customerId=432
Output: /getCustomers?customerId=NULL
Thank you.
Solution
Using sed -r 's/(=)([0-9]+)/\1NULL/g' inputfile.txt
on inputfile:
/getProduct?productId=1234&quanity=4
/getCustomers?customerId=432
/getCustomers3?customerId=432
we get:
/getProduct?productId=NULL&quanity=NULL
/getCustomers?customerId=NULL
/getCustomers3?customerId=NULL
Only digits appearing after the equal sign are changed.
Answered By - Pankaj Saini Answer Checked By - Timothy Miller (WPSolving Admin)