how can I combine these lines

后端 未结 4 1145
轻奢々
轻奢々 2021-01-24 03:44

How can I combine these lines (NOTE: this is just an excerpt from a much larger file):

interface GigabitEthernet0/0
 no ip proxy-arp
interface GigabitEthernet0/0         


        
相关标签:
4条回答
  • 2021-01-24 04:19
     awk '{printf "%s%s",$0,(NR%2?"|":"\n")}' file
    
    0 讨论(0)
  • 2021-01-24 04:22
    while IFS= read line1 && IFS= read line2; do
        printf "%s | %s\n" "$line1" "$line2"
    done < file.txt
    
    0 讨论(0)
  • 2021-01-24 04:24

    Try this sed one-liner:

    sed 'N;s/\n/ | /;s/\r//g' file.txt
    
    0 讨论(0)
  • 2021-01-24 04:35

    paste can do it:

    paste -d '|' - - < file
    
    0 讨论(0)
提交回复
热议问题