I have a file with comments:foobarstuff#Do not show this...morestuffevenmorestuff#Or thisI just want to print all the uncommented code:foobarstuffmorestuffevenmorestuffBeing able to strip comments out of a file is so important...  What is a good way to do it?
How to remove all comments from a file?
shell script;text processing;awk;sed;grep
One way to remove all comments is to use grep with -o option:grep -o '^[^#]*' filewhere-o: prints only matched part of the linefirst ^: beginning of the line[^#]*: any character except # repeated zero or more timesNote that empty lines will be removed too, but lines with only spaces will stay.