Reputation: 875
I have a bash script that runs and outputs to a text file however the colour codes it uses are also included what i'd like to know is how to remove them from the file, ie
^[[38;1;32mHello^[[39m
^[[38;1;31mUser^[[39m
so I just want to be left with Hello and User, so something like sed -r "special characters" from file A save to file B
Upvotes: 1
Views: 1084
Reputation: 10039
sed 's/\^\[\[[^m]*m//g'
remove (all) part of line starting with ^[[
until first m
Upvotes: 2
Reputation: 41456
Some like this:
awk '{sub(/\^\[\[38;1;[0-9][0-9]m/,x);sub(/\^\[\[39m/,x)}1'
Hello
User
Upvotes: 0