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
inputfile
1111,
2222,
3333,
4444
outputfile
1111,
2222,
3333,
4444 );
GO
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
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
$ cat input
1111,
2222,
3333,
4444
$ sed -e '${s/$/ );\nGO/}' input
1111,
2222,
3333,
4444 );
GO
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.
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
sed -e '$s/4444/4444 );\nGO/' input