I have this file, ipaddresses.txt

And this file, cidr.txt


And I want the output file to be like this:

How to achieve this?

  • 5
    Why sed, specifically? have you considered alternatives - such as paste -d/ ipaddresses.txt cidr.txt ? Jul 21, 2019 at 23:01
  • Because I only know sed to do this kind of task, I will edit my thread. By the way, I tried using paste, it doesn't append to the last line, but it append a new line each.
    – annahri
    Jul 21, 2019 at 23:14
  • 1
    @Annahri The paste command by steeldriver works. Do you not have GNU paste or is there something with your environment such as an alias? Jul 21, 2019 at 23:36
  • @NasirRiley I'm using bash on Ubuntu on Windows 10 (what is the correct term for this?) I did paste -d/ ipaddresses.txt cidr.txt > out.txt. When I try to do it without outputting a file, It prints a different behaviour. It adds \ in the beginning of each line but It does correctly for the very last line. Hmm
    – annahri
    Jul 21, 2019 at 23:53
  • 2
    @Annahri do your files have Windows style (CRLF) line endings by any chance? Jul 21, 2019 at 23:54

1 Answer 1


You want to use paste:

$ paste -d '/' ipaddresses.txt cidr.txt

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .