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

How to get the individual exit codes of all the shell scripts invoked by a parent shell script?
why shell for expression cannot parse xargs parameter correctly
Passing System date to Sqoop
How to run shell script for mac
How to grep and copy files with spaces in their names
.bat file to shell conversion to pass variable between Jenkin build step and post build step
How to fix ctrl+c inside a docker container
Find and replace � in folders and files recursively
Error updating pip version on mac
Shell Scripting: How to choose a randow number from three values?
Systemd Timer not executing shell script
Running Command Lines in a makefile
how to set string to timestamp in unix?
Fish shell error
awk: “not enough arguments to satisfy format string” error in script
Arithmetic calculation causes “operator expected”

Categories

HOME
android
beautifulsoup
eslint
wakanda
css3
jax-rs
hessian
gradient
emscripten
nested-if
banner
angularfire2
nfs
syntaxnet
google-schemas
vimdiff
mod-security
automatic-ref-counting
symmetricds
eip
capistrano3
identity-management
sse
nim
charles
undertow
gulp-watch
easeljs
qliksense
direct3d11
comparator
onload
slidetoggle
stackexchange
intersystems-cache
handler
cppreference
bioinformatics
jaws
uitapgesturerecognizer
scrollview
aws-codecommit
dumpbin
jett
imx6
swagger-php
openproject
ideascript
numberpicker
oracle-service-bus
xmldocument
x++
jide
dynamic-linq
term
automapper-5
gitlist
dtsearch
pair-programming
amq
modelsim
git-flow
pdf-conversion
webjars
mapinfo
vorpal.js
dbamp
database-relations
concept-insights
libvlc
boomerang
gocql
rubaxa-sortable
pax-exam
graphics2d
git-ftp
uvc
umlgraph
qtwebengine
jbake
pseudo-class
jjaql
tinyxml
paste
accesscontrolexception
openargs
gwt-openlayers
eclipse-kepler
tlf
cnf
poker
pdfviewer
cakephp-1.2
faye
boost-signals
josql
isa-swizzling
flex-mobile
landscape-portrait
u2netdk
pylucene
cloudfiles
mtu
resharper-6.0
uideviceorientation
application-verifier
murmurhash
spread
complex-event-processing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App