[질문] ifconfig ip를 추출하여 sed로 기존 문자 치환

글쓴이: 익명 사용자 / 작성시간: 금, 2019/07/12 - 11:31오전
[root@localhost ~]# ifconfig
ens33: flags=4163 mtu 1500
inet 172.16.47.154 netmask 255.255.255.0 broadcast 172.16.47.255
inet6 fe80::20c:29ff:fe39:5d04 prefixlen 64 scopeid 0x20
ether 00:0c:29:39:5d:04 txqueuelen 1000 (Ethernet)
RX packets 44880 bytes 30980088 (29.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 10768 bytes 4855166 (4.6 MiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
[root@localhost ~]# cat t.txt
1
ifconfig로 추출한 IP를 t.txt 내용에 있는 1을 IP로 치환하고 싶은데,
방법을 못 찾아서 문의 드립니다. 혹시 아시는 분들은 도움 부탁드립니다.
Forums:
파이썬3 으로 시도해봤습니다;;;
소스코드: https://gitlab.com/soyeomul/test/blob/master/161875.py
[ibus-hangul(서라운딩 패치판)에서 작성했씁니다]
음 ..
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
IPv4 주소 추출 정규표현식이 ymir님이 더
IPv4 주소 추출 정규표현식이 ymir님이 더 정확한거 같아요. 아름다운 코드 감사드립니다^^^
--
^고맙습니다 감사합니다_^))//
댓글 달기