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 replace spaces with “_” in the data between brackets using shell script?
Permission denied at hdfs
How to get error output and store it in a variable or file
simple unix script to check a txt file and do another job
How to store an output of shell script to a variable in Unix?
Comparing two variables in a for loop
Translate newline to comma
Unexpected end of file
Building Bochs using CygWin: “no rule to make target”
copy multiple files to null directory
Unix: create a directory with the same name as the working directory
how extract text between particular html tag in script
How to parse commands and color it?
How to run a script at Cygwin shell exit?
How do I show the results of pattern-matching goals with several free variables in SWI-Prolog from a shell invocation?
Appending ruby partial w('<%= characters) to end of file with SED

Categories

HOME
android
phpword
google-cloud-platform
cheerio
vscode-extensions
bitbucket-api
yandex
entity-framework-core
carousel
alsa
square
onclick
limit
interpolation
gluon-mobile
angularfire2
computer-science
teechart
performancepoint
fabric.io
pcl-crypto
mautic
xcodebuild
pybossa
onedrive-api
scsi
dynamic-sql
enterprise-miner
replication
drive
kendo-mobile
gulp-watch
hta
scriptella
comparator
dynamically-generated
google-api-client
tiki-wiki
pic32
appirater
bringtofront
uitapgesturerecognizer
corenlp-server
panoramas
mustache
rselenium
login-script
joomla2.5
jwplayer6
openerp-7
reason
sql-server-ce
connection-pool
odroid
spring-mvc-test
setup.py
file-sharing
clang++
x++
libgphoto2
dbcontext
stdmap
edit
filehandle
oozie-coordinator
polyline
cvxpy
meteor-packages
signalr.client
udpclient
dbamp
cortex-m
libav
jbase
concurrentmodification
opl
slash
eoferror
jdk1.7
amiga
apache-spark-1.3
rapidsvn
theos
browserify-shim
big-ip
sql-scripts
wcm
create.js
ignite-ui
cuba
grails-domain-class
tinyxml
ios8-extension
paste
authlogic
maven-scm
conditionaltagsupport
code-duplication
octal
android-icons
windows-98
tree-balancing
listitem
floating-point-exceptions
cgimage
google-floodlight
quotation-marks
appledoc
lalr
interop-domino
firefox-3
unmanagedresources
commercial-application

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