How to mask query param values in Linux [closed]












-1















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










share|improve this 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


















-1















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










share|improve this 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
















-1












-1








-1








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










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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





















  • 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














1 Answer
1






active

oldest

votes


















3














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





share|improve this answer
































    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    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





    share|improve this answer






























      3














      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





      share|improve this answer




























        3












        3








        3







        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





        share|improve this answer















        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






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 22 '18 at 8:58

























        answered Nov 22 '18 at 8:53









        georgexshgeorgexsh

        10.2k11236




        10.2k11236















            Popular posts from this blog

            To store a contact into the json file from server.js file using a class in NodeJS

            Redirect URL with Chrome Remote Debugging Android Devices

            Dieringhausen