Sometimes, you just want to see the code ... Let's say you want to look at a bash script, but strip out all the comments. Here's a sample command using grep that will display a bash script, without comments, to stout:
grep -v "^#" commented-script.shNotes:
- "-v" means invert the selection; i.e., only display the lines in the file that don't match.
- "^#" is the regular expression that matches "lines that start with #".
- "^" means only match the beginning of the line.
- Replace "commented-script.sh" with the file name of the file you want to strip.
- This command strips single line comments from any programming language. Just change the comment line character (";" instead of "#" for example).
- If you just want to read the comments, drop the "-v" switch.