shell


sed add line at the end of file


I trying to add a line at the end of file (/root/test.conf) with sed. I use FreeBSD and when I try to add a simple line, I always get several errors like:
extra characters at the of command
undefined label 'est.conf'
The file is like this:
#Test
firstLine
secondLine
!p.p
*.*
And I want to add something like this:
(return \n)
!word
other (5 tab between "other" and "/usr/local") /usr/local
If it's not possible with sed, there are another options?
Thank you!
It doesn't sound like you need to use sed at all, maybe just cat with a heredoc:
cat test.conf - <<EOF
whatever you want here
more stuff
EOF
The - argument causes cat to listen on standard input, which allows you to use a heredoc as well as a file.
You can add a redirect > tmp before <<EOF to output to another file called tmp.
To add literal tabs in the interactive terminal, you can use Ctrl-v followed by Tab.
You don't need any special tools like sed to add some lines to the end of files.
$ echo "This is last line" >>file
#or
$ printf "This is last line\n" >>file
works just fine in almost any platform. You might need to escape special characters though, or enclose them in single/double quotes.

Related Links

find: missing argument to `-exec' error from shell script
Build failed while appending line in source of docker container
Delete file in multiple directories on remote server using SSH
jq - Cannot index string with string
awk or shell script to change format of a tab delimited file
Can't execute remote ssh command from irssi
Adjust PDF canvas maximum page size
Convert date and time to seconds
Oozie shell action doesn't send mail notification
How to get the impala query output log into a variable using unix shell script?
teradata table error using multiload script
awk command to print multiple columns using for loop
Bash Script for loop?
why one bteq script works, but not the other
CoovaChilli redirect to a new page on successfull login, to display user account balance
First and last days of month given a specific day of that month - shell

Categories

HOME
awk
string
ggplot2
forms
android-studio-2.2
twig
swt
apache-spark-mllib
battery
sh
solver
pclxl
rds
opengl-3
rcloud
distribution
appcelerator-studio
opengl-es-3.0
openbugs
endpoint
do-while
esoteric-languages
forgot-password
sencha-touch
sar
cgbitmapcontext
postscript
joptionpane
pchart
flask-sqlalchemy
xunit
draft-js-plugins
delimiter
intersystems-cache
tpm
user-defined-functions
finagle
database-comparison
biztalk-rule-engine
openwhisk
hibernate-search
protege4
hivemq
magento-1.9.3
optimizely
puredata
pom.xml
proget
builder
serde
user-defined-fields
facebook-pixel
compiler-design
java-6
ngmaterial
skin
reshape
cd-burning
polyline
pushbots
relativelayout
character-replacement
grgit
vigenere
rubaxa-sortable
eoferror
sha512
ms-access-2000
user-permissions
xmltype
phpldapadmin
adehabitathr
android-cookiemanager
trdion2011
template-deduction
xml-dsig
grails-plugin-rabbitmq
dct
gnumeric
terminate
extjs2
high-resolution
visual-studio-express
notorm
gd-graph
jeromq
sqlclr
catransform3d
listactivity
timthumb
svk
maven-1
hbm2java
linfu-dynamicproxy
appliance

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile