How to mask query param values in Linux [closed]
Need help on below requirement.
I have a file with list of URLs and need to mask query param values as shown in below example in Linux.
http://hostname:port/uri?data=value&data1=value2&data3=value3
to
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
thanks
linux bash shell replace
closed as too broad by tripleee, jww, Makyen, Pearly Spencer, Machavity Nov 24 '18 at 15:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
Need help on below requirement.
I have a file with list of URLs and need to mask query param values as shown in below example in Linux.
http://hostname:port/uri?data=value&data1=value2&data3=value3
to
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
thanks
linux bash shell replace
closed as too broad by tripleee, jww, Makyen, Pearly Spencer, Machavity Nov 24 '18 at 15:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
2
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43
add a comment |
Need help on below requirement.
I have a file with list of URLs and need to mask query param values as shown in below example in Linux.
http://hostname:port/uri?data=value&data1=value2&data3=value3
to
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
thanks
linux bash shell replace
Need help on below requirement.
I have a file with list of URLs and need to mask query param values as shown in below example in Linux.
http://hostname:port/uri?data=value&data1=value2&data3=value3
to
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
thanks
linux bash shell replace
linux bash shell replace
asked Nov 22 '18 at 7:05
rdev1991rdev1991
83
83
closed as too broad by tripleee, jww, Makyen, Pearly Spencer, Machavity Nov 24 '18 at 15:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as too broad by tripleee, jww, Makyen, Pearly Spencer, Machavity Nov 24 '18 at 15:15
Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
2
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43
add a comment |
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
2
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
2
2
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43
add a comment |
1 Answer
1
active
oldest
votes
you could replace any character that is not a &
, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' |
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
you could replace any character that is not a &
, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' |
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
add a comment |
you could replace any character that is not a &
, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' |
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
add a comment |
you could replace any character that is not a &
, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' |
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
you could replace any character that is not a &
, it is more efficient than enumerating all possible ranges:
$ echo 'http://hostname:port/uri?data=value&data1=va%20lue2&data3=value3' |
sed -r 's/=[^&]+/=XXX/g'
http://hostname:port/uri?data=XXX&data1=XXX&data3=XXX
edited Nov 22 '18 at 8:58
answered Nov 22 '18 at 8:53
georgexshgeorgexsh
10.2k11236
10.2k11236
add a comment |
add a comment |
You can use python and docs.python.org/3/library/urllib.parse.html
– Diego Torres Milano
Nov 22 '18 at 7:12
2
it is simple task, what have you tried so far?
– georgexsh
Nov 22 '18 at 7:40
I tried sed command as follows sed 's/=[0-9]+/=XXX/g', however in some URL the param value contains just alphabets, alpha numeric (in both case), Special characters (%20 etc).
– rdev1991
Nov 22 '18 at 8:43