
입력 파일:
sip:[email protected]:5060;user=phone
sip:+17738959697;[email protected]:5060;user=phone
sip:[email protected];user=phone
또는를 사용하여 grep
다음 출력을 어떻게 얻을 수 있습니까 sed
?
+16309608112
+17738959697;npdi
7739469234
답변1
awk를 사용하세요:
awk -F'[:@]' '{print $2}' file
+16309608112
+17738959697;npdi
7739469234
답변2
이렇게 하면 원하는 작업이 수행됩니다.
$ cat /tmp/your/input | sed -e 's/.*:\(\S\+\)@.*/\1/g'
+16309608112
+17738959697;npdi
7739469234
답변3
cut
다음을 사용할 수도 있습니다 .
cut -d: -f2 file | cut -f1 -d@
# output
+16309608112
+17738959697;npdi
7739469234
중간에 빈 줄이 정말로 필요합니까?