亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫
最近訪問板塊 發(fā)新帖
查看: 2284 | 回復(fù): 5
打印 上一主題 下一主題

[文本處理] sed能否用file1的內(nèi)容替換掉file2特定行的內(nèi)容 [復(fù)制鏈接]

論壇徽章:
2
亥豬
日期:2015-01-19 15:47:392015年亞洲杯之朝鮮
日期:2015-04-08 16:27:18
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2015-05-21 15:40 |只看該作者 |倒序?yàn)g覽



如圖
咋用sed讓file1的字符串替換file2文件里的特定行的字符串,謝謝

論壇徽章:
2
2015年亞洲杯之伊拉克
日期:2015-04-13 10:55:1115-16賽季CBA聯(lián)賽之山西
日期:2016-05-16 09:54:41
2 [報(bào)告]
發(fā)表于 2015-05-21 15:56 |只看該作者
沒明白你說的是什么。。。。

論壇徽章:
2
亥豬
日期:2015-01-19 15:47:392015年亞洲杯之朝鮮
日期:2015-04-08 16:27:18
3 [報(bào)告]
發(fā)表于 2015-05-21 16:20 |只看該作者
就是用下面那張圖里的內(nèi)容替換上面那張圖的特定的三行,address,netmask,gateway這三行回復(fù) 2# little_angel


   

論壇徽章:
2
亥豬
日期:2015-01-19 15:47:392015年亞洲杯之朝鮮
日期:2015-04-08 16:27:18
4 [報(bào)告]
發(fā)表于 2015-05-21 16:22 |只看該作者
  1.         address 192.168.1.123
  2.         netmask 255.255.255.0
  3.         gateway 192.168.1.1
復(fù)制代碼
  1. # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)

  2. # The loopback interface
  3. auto lo
  4. iface lo inet loopback


  5. # Wireless interfaces
  6. #
  7. # Example of an unencrypted (no WEP or WPA) wireless connection
  8. # that connects to any available access point:
  9. #
  10. iface wlan0 inet dhcp
  11.         wireless_mode managed
  12.         wireless_essid any
  13. #
  14. #
  15. # Same as above but locked to a specific access point:
  16. #
  17. #iface wlan0 inet dhcp  
  18. #        wireless_mode managed
  19. #        wireless-essid some-essid
  20. #
  21. # A WEP encrypted connection locked to a specific access point:
  22. #
  23. #iface wlan0 inet dhcp  
  24. #        wireless-essid some-essid
  25. #        wireless-key s:My-PlainText-Password
  26. #        wireless-mode managed                  
  27. #
  28. # A WPA1 or WPA2 encrypted connection locked to a specific access point.
  29. # This is the best option for non-roaming, single-network usage.
  30. # Note that your card may require a firmware update to use WPA.
  31. # Some distributions install a temporary volatile firmware update on ifup.
  32. #
  33. #iface wlan0 inet dhcp                                                   
  34. #        wpa-essid some-essid                                          
  35. #        wpa-psk My-PlainText-Password                                             
  36. #
  37. # A WPA1 or WPA2 encrypted connection using an external configuration file
  38. # for wpa-supplicant. This is the way to go if you need to configure multiple
  39. # networks with different keys and / or WPA settings and roaming support.
  40. #
  41. # iface wlan0 inet dhcp
  42. #    wpa-conf /etc/wpa_supplicant.conf
  43. #    wpa-driver hostap



  44. iface atml0 inet dhcp

  45. # Wired or wireless interfaces
  46. auto eth0
  47. iface eth0 inet static
  48.         address 192.168.1.22
  49.         netmask 255.255.255.0
  50.         gateway 192.168.1.1

  51. #iface eth0 inet dhcp
  52. iface eth1 inet dhcp

  53. # Ethernet/RNDIS gadget (g_ether)
  54. # ... or on host side, usbnet and random hwaddr
  55. iface usb0 inet static
  56.         address 192.168.0.202
  57.         netmask 255.255.255.0
  58.         network 192.168.0.0
  59.         gateway 192.168.0.200


  60. # Zaurus 2.4 Lineo net_fd; obsolete
  61. iface usbd0 inet static
  62.         address 192.168.129.201
  63.         netmask 255.255.255.0
  64.         network 192.168.129.0
  65.         gateway 192.168.129.200

  66. # iPAQ 2.4 mach-sa1100/usb-eth
  67. # (192.168.0.202 is the iPAQ's IP, 192.168.0.200 is the host's IP)
  68. iface usbf inet static
  69.         address 192.168.0.202
  70.         netmask 255.255.255.0
  71.         network 192.168.0.0
  72.         gateway 192.168.0.200

  73. # Bluetooth networking
  74. iface bnep0 inet dhcp
復(fù)制代碼

論壇徽章:
145
技術(shù)圖書徽章
日期:2013-10-01 15:32:13戌狗
日期:2013-10-25 13:31:35金牛座
日期:2013-11-04 16:22:07子鼠
日期:2013-11-18 18:48:57白羊座
日期:2013-11-29 10:09:11獅子座
日期:2013-12-12 09:57:42白羊座
日期:2013-12-24 16:24:46辰龍
日期:2014-01-08 15:26:12技術(shù)圖書徽章
日期:2014-01-17 13:24:40巳蛇
日期:2014-02-18 14:32:59未羊
日期:2014-02-20 14:12:13白羊座
日期:2014-02-26 12:06:59
5 [報(bào)告]
發(fā)表于 2015-05-21 17:06 |只看該作者
回復(fù) 4# 791605975

$ awk 'FNR==NR{a[$1]=$2;next}/^iface /{g=($2=="eth0")?1:0}g&&/^[^#]/{if(a[$1])sub($1".*$",$1" "a[$1])}1' file1 file2 > file3

$ cat file1
        address 192.168.1.123
        netmask 255.255.255.0
        gateway 192.168.1.1


$ grep -A3 '^iface eth0' file2
iface eth0 inet static
        address 192.168.1.22
        netmask 255.255.255.0
        gateway 192.168.1.1

$ grep -A3 '^iface eth0' file3
iface eth0 inet static
        address 192.168.1.123
        netmask 255.255.255.0
        gateway 192.168.1.1


論壇徽章:
20
卯兔
日期:2015-01-26 22:05:142015亞冠之薩濟(jì)拖拉機(jī)
日期:2015-09-10 15:15:282015亞冠之阿爾希拉爾
日期:2015-09-25 17:37:53程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-10-03 06:20:00程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-09 06:20:00CU十四周年紀(jì)念徽章
日期:2015-12-17 09:07:15程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-25 06:20:34程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-25 06:20:34程序設(shè)計(jì)版塊每日發(fā)帖之星
日期:2015-12-25 06:20:342015亞冠之廣州富力
日期:2015-08-27 19:29:56每日論壇發(fā)貼之星
日期:2015-08-26 06:20:002015亞冠之阿爾希拉爾
日期:2015-05-18 17:26:27
6 [報(bào)告]
發(fā)表于 2015-05-21 21:38 |只看該作者
回復(fù) 1# 791605975
$sed -n 'h;/^iface eth0/{:a;H;n;/^$/!ba;g;s/\n.*//;r file1
};p' file2 > file3

$ cat file1
        address 192.168.1.123
        netmask 255.255.255.0
        gateway 192.168.1.1

$ grep -A3 '^iface eth0' file2
iface eth0 inet static
        address 192.168.1.22
        netmask 255.255.255.0
        gateway 192.168.1.1

$ grep -A3 '^iface eth0' file3
iface eth0 inet static
        address 192.168.1.123
        netmask 255.255.255.0
        gateway 192.168.1.1
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP