├── ansirem.py └── README.md /ansirem.py: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | def remove_ansi_codes_from_file(filename): 4 | # Regular expression pattern to match ANSI codes 5 | ansi_escape = re.compile(r'\x1B\[[0-?]*[ -/]*[@-~]') 6 | 7 | with open(filename, 'r') as f: 8 | content = f.read() 9 | 10 | cleaned_content = ansi_escape.sub('', content) 11 | 12 | with open(filename, 'w') as f: 13 | f.write(cleaned_content) 14 | 15 | if __name__ == '__main__': 16 | import sys 17 | if len(sys.argv) < 2: 18 | print("Usage: python3 script_name.py filename") 19 | else: 20 | remove_ansi_codes_from_file(sys.argv[1]) 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ANSIrem 2 | 3 | ANSIrem will remove all ANSI characters on a given text file (updating the same file, not creating a new one), for example: 4 | 5 | ````none 6 | $ cat results.txt 7 | ^[[92mtest.example.com^[[0m^[[94m 8 | $ python3 ASNIrem.py results.txt 9 | $ cat results.txt 10 | test.example.com 11 | ```` 12 | 13 | # Why ANSIrem? 14 | 15 | Crafted to tackle the inconvenience caused by certain tools (such as httpx, amass, and others) that output results with distracting colors. No longer will you need to rerun workflows or add additional flags to adjust the output. With this script, seamless workflow is just a click away. 16 | --------------------------------------------------------------------------------