Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. grep -v '#'
  2.  
  3. grep -v '^#'
  4.  
  5. $ cat ./testscript.sh
  6. #!/bin/bash
  7.  
  8. # comment
  9. set -vn
  10. echo "Hello World" # another comment
  11. $ ./testscript.sh
  12. echo "Hello World" # another comment
  13.  
  14. gcc -fpreprocessed -dD -E test.c
  15.  
  16. import tokenize
  17. import io
  18. import sys
  19.  
  20. def nocomment(s):
  21. result = []
  22. g = tokenize.generate_tokens(io.BytesIO(s).readline)
  23. for toknum, tokval, _, _, _ in g:
  24. # print(toknum,tokval)
  25. if toknum != tokenize.COMMENT:
  26. result.append((toknum, tokval))
  27. return tokenize.untokenize(result)
  28.  
  29. print(nocomment(sys.stdin.read()))
  30.  
  31. #!/bin/sh
  32. case "$1" in
  33. *.py)
  34. remove-comments.py < "$1"
  35. break
  36. ;;
  37. *.c|*.C|*.cc)
  38. gcc -fpreprocessed -dD -E "$1"
  39. break
  40. ;;
  41. *)
  42. echo I do not know how to remove comments from $1, sorry
  43. break
  44. ;;
  45. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement