Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- grep -v '#'
- grep -v '^#'
- $ cat ./testscript.sh
- #!/bin/bash
- # comment
- set -vn
- echo "Hello World" # another comment
- $ ./testscript.sh
- echo "Hello World" # another comment
- gcc -fpreprocessed -dD -E test.c
- import tokenize
- import io
- import sys
- def nocomment(s):
- result = []
- g = tokenize.generate_tokens(io.BytesIO(s).readline)
- for toknum, tokval, _, _, _ in g:
- # print(toknum,tokval)
- if toknum != tokenize.COMMENT:
- result.append((toknum, tokval))
- return tokenize.untokenize(result)
- print(nocomment(sys.stdin.read()))
- #!/bin/sh
- case "$1" in
- *.py)
- remove-comments.py < "$1"
- break
- ;;
- *.c|*.C|*.cc)
- gcc -fpreprocessed -dD -E "$1"
- break
- ;;
- *)
- echo I do not know how to remove comments from $1, sorry
- break
- ;;
- esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement