Skip to content

Instantly share code, notes, and snippets.

@kaku87
Created March 20, 2018 06:49
Show Gist options
  • Save kaku87/d4f82fe8928ada57dfb00be1707f0f4a to your computer and use it in GitHub Desktop.
Save kaku87/d4f82fe8928ada57dfb00be1707f0f4a to your computer and use it in GitHub Desktop.
file replace
#!/bin/bash
python
filetosearch = '/home/ubuntu/ip_table.txt'
texttoreplace = 'tcp443'
texttoinsert = 'udp1194'
s = open(filetosearch).read()
s = s.replace(texttoreplace, texttoinsert)
f = open(filetosearch, 'w')
f.write(s)
f.close()
quit()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment