adding brackets

Hi,
If you suppose that you have two columns of numbers, and I want to merge these two columns into one and put a bracket around it. and perphaps add a dash between two numbers.

input.txt

1 2 
3 4 
5 6
7 8

output.txt

(1-2)
(3-4)
(5-6)
(7-8)

Thanks in advance!

$ while read LINE; do echo "($(echo ${LINE}| tr -s ' ' '-'))"; done < input.txt
(1-2)
(3-4)
(5-6)
(7-8)
1 Like
$ awk '{print "("$1"-"$2")"}' input.txt
(1-2)
(3-4)
(5-6)
(7-8)
1 Like