모든 파일에서 첫 번째 주석 블록을 꺼내기 위해 하나의 라이너를 찾고 있습니다. 댓글 블록은 다음과 같습니다.시작 줄 x 개를 다른 파일로 끌어 오기위한 Bash 스크립트
/*
* This is a
* comment block
*/
나는 sed와 함께 놀려고했지만 제대로 작동하지 못했습니다. 도움?
#!/usr/bin/env python
import sys
f = open(sys.argv[1])
incomment = False
for line in f:
line = line.rstrip("\n")
if "*/" in line:
print line
break
elif "/*" in line:
incomment = True
print line
elif incomment:
print line
실행 :
python code.py <filename>
Annnnnnd 감사합니다. –
좋은 것이지만 100 % 작동하지 않습니다. 그것은 내 대답에 두 번째 샘플 파일뿐만 아니라 여러 줄 주석을 제공합니다. – ghostdog74