5

I am trying to combine work tvg-name with multiple lines of a file

tr '\n' '~' < file1.txt | sed s/~/tvg-name/g

results in only first single-line print

tvg-namegama1

my file1.txt has more than 50 lines e.g.

gama1
beta2
tera3

and so on more than 50 lines

required output

tvg-name="gama1"
tvg-name="beta2"

and so on till the file ends.

Rohit Gupta
  • 348
  • 2
  • 4
  • 11
Rizwan.A
  • 53
  • 5

1 Answers1

7

You can use sed alone, like so:

sed 's/.*/tvg-name="&"/' file1.txt

That will prepend tvg-name=" and append " to each line in your file.

That can also be done with awk, like so:

awk '{printf "tvg-name=\"%s\"\n", $0}' file1.txt

Or with pure bash, like so:

while IFS= read -r l; do printf 'tvg-name="%s"\n' "$l"; done < file1.txt
Dan
  • 14,180
Raffa
  • 34,963