Using awk and sed to replace text

Good Day Every one

I have a problem finding and replacing text in some large files that will take a long time to manually edit.

Example text file looks like this

#Example Large Text File

unix
linux
dos
squid
bind
dance
bike
car
plane

What im trying to do is to edit all the lines at the same time and add " " to each line so it would look like this.

#Example Large Text File

"unix"
"linux"
"dos"
"squid"
"bind"
"dance"
"bike"
"car"
"plane"

i managed to use sed to change one line but then i need to know what the text in the line is to change it.

sed -i 's/bind/"bind"/g' large-txt-file

So what i want to do is to change all the lines regardless of what the text on that line is.

i have tried

sed -i 's/*/"*"/g' large-txt-file

and

awk '{sub(*, "*")};' large-text-file

Im new to using awk and sed.

Any help would be greatly appreciated.

:stuck_out_tongue:

Test it with this one:

sed 's/^.*$/"&"/g' largefile.txt

Make the change to the file with this one and create a backup (largefile.txt.ORIG):

sed -i.ORIG 's/^.*$/"&"/g' largefile.txt

Thank you in2nix4life it worked for me !.

No problem. :slight_smile:

The sed expression can be simplified

sed 's/.*/"&"/'

Alternative

sed 's/^/"/; s/$/"/'