0

I'm trying to add } at end of each line using sed

i use the following command: sed -i 's/$/}/g' test.txt

But it adds } at end of the file instead. What is the correct command?

I am using kali subsystem on windows 10 is that the problem? how can I fix this?

Jotne
  • 40,548
  • 12
  • 51
  • 55
Rembo
  • 43
  • 1
  • 9
  • 4
    This command is correct, it gives me `}` at end of each line. Try `dos2unix file_name` to see if it has wrong formatting. – Jotne Jul 20 '19 at 18:48
  • maybe real kali and kali in windows 10 are different? – Rembo Jul 21 '19 at 06:49

1 Answers1

-2

You should use line end character for replace part in sed statement.

Example:

$ cat data 
1
2
3
4
5
6
7
8
9
10
$ cat data |sed -r 's#$#}$#g'
1}$
2}$
3}$
4}$
5}$
6}$
7}$
8}$
9}$
10}$

I hope it helps.

Ali Okan Yüksel
  • 338
  • 1
  • 13