Link to home
Start Free TrialLog in
Avatar of digs developer
digs developer

asked on

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
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Does the last line always end in 4444???

sed -e '$s/4444/4444 );\nGO/' input
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
Here is my test....

$ cat input
1111,
2222,
3333,
4444

$ sed -e '${s/$/ );\nGO/}' input
1111,
2222,
3333,
4444 );
GO
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

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.
@slightwv, would that add it AFTER the last line?
Yes but look at what they asked:
How to add ); Go in last line in file ?
@slightwv, If you look at their example they want ;) added to the last line of text, and the word GO on the last line.
Missed the 'go' part of the original question.

If they want the GO, just add it to the echo.
@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.
ASKER CERTIFIED SOLUTION
Avatar of slightwv (䄆 Netminder)
slightwv (䄆 Netminder)

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial