큰따옴표로 묶인 단어를 out.txt로 한 줄로 캡처하는 방법
more input.txt
"OQ -63/ECC/UK/JDA/adRedprairie" "OQ -63/ECC/UK/JDA/adRedprairie.ear" "OQ- 63/ECC/UK/JDA/adRedprairie.xml"
"OQ/CZ/Ecomphos/216_06/OM-S03" "OQ/CZ/Ecomphos/216_06/OM-S03.ear" "OQ/CZ/Ecomphos/216_06/OM-S03.xml"
more out.txt
OQ -63/ECC/UK/JDA/adRedprairie
OQ -63/ECC/UK/JDA/adRedprairie.ear
Q-63/ECC/UK/JDA/adRedprairie.xml
OQ/CZ/Ecomphos/216_06/OM-S03
OQ/CZ/Ecomphos/216_06/OM-S03.ear
OQ/CZ/Ecomphos/216_06/OM-S03.xml
답변1
예를 들어 다음 과 같이 사용할 수도 있습니다 grep
.
grep -o '[^"]\+' input.txt | grep -v '^ *$'
산출:
OQ -63/ECC/UK/JDA/adRedprairie
OQ -63/ECC/UK/JDA/adRedprairie.ear
OQ- 63/ECC/UK/JDA/adRedprairie.xml
OQ/CZ/Ecomphos/216_06/OM-S03
OQ/CZ/Ecomphos/216_06/OM-S03.ear
OQ/CZ/Ecomphos/216_06/OM-S03.xml
답변2
Perl이 구조에 옵니다:
perl -lne 'print for /"([^"]+)"/g' -- input.txt