How to add ); Go in last line in file ?

How to add ); Go in last line in file ?

inputfile
1111,
2222,
3333,
4444

outputfile
1111,
2222,
3333,
4444 );
GO
digs developerAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

savoneCommented:
Does the last line always end in 4444???

sed -e '$s/4444/4444 );\nGO/' input
0
savoneCommented:
If the last line does not always end in 4444, this will append to whatever the last line may be:

sed -e '${s/$/ );\nGO/}' input
0
savoneCommented:
Here is my test....

$ cat input
1111,
2222,
3333,
4444

$ sed -e '${s/$/ );\nGO/}' input
1111,
2222,
3333,
4444 );
GO
0
10 Tips to Protect Your Business from Ransomware

Did you know that ransomware is the most widespread, destructive malware in the world today? It accounts for 39% of all security breaches, with ransomware gangsters projected to make $11.5B in profits from online extortion by 2019.

slightwv (䄆 Netminder) Commented:
Would you just not do:
echo ");" >> input

If you want GO, just add it as well...  The question didn't ask for it so I didn't add it.
0
savoneCommented:
@slightwv, would that add it AFTER the last line?
0
slightwv (䄆 Netminder) Commented:
Yes but look at what they asked:
How to add ); Go in last line in file ?
0
savoneCommented:
@slightwv, If you look at their example they want ;) added to the last line of text, and the word GO on the last line.
0
slightwv (䄆 Netminder) Commented:
Missed the 'go' part of the original question.

If they want the GO, just add it to the echo.
0
savoneCommented:
@slightwv, again, it will not append ); to the last line, it will append it to the end of the file on it's own line.
0
slightwv (䄆 Netminder) Commented:
Again, OP asked "in last line in file"

This is my last post until the OP comes back.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.