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

psexec fails against windows 10 remote target
Replacing a particular string in a unix script with sed [duplicate]
#python3.x Importing in Shell
making variable with the values of another variable in unix shell scripting
How to generate random numbers from a given range with provided distribution probability
how to find out particular URL is correct URL or not in shell script using curl command
How to set less to clear the screen on exit only if the output fills more than a single page?
Addition in awk failing
Converting file with single field into multiple comma separated fields
Need to get output of command as value for variable in shell script
How to execute VSTest.Console.exe using a shell script with multiple filenames
shell command to copy text appears to work but formats without returns in applescript to filemaker
gnuplot with muliple files using loop
Ensuring a shell script to be executed as lsf job only
hive script file not found exception
Bringing an OS X application to the front even if it's a different Mission Control space

Categories

HOME
search
twitter-bootstrap-3
time-complexity
zend-framework
toolbox
vscode-extensions
banner
trac
fabric.io
endeca
resultset
angular-dart
endpoint
mathprog
identity-management
production
springfox
parcelable
displaytag
maze
interbase
underscore.js
intersystems-cache
android-things
sinch
utorrent
weather
dumpbin
latitude-longitude
reactivekit
modernizr
protein-database
password-protection
google-data-api
x++
mesosphere
netbeans6.8
amq
wpas
edit
android-testing
quicktime
offline.js
py2neo
cd-burning
reporting-services-2012
seek
preprocessor
burrows-wheeler-transform
beamer
delta
observablecollection
libav
jparsec
wiredep
roadkill-wiki
text-search
mod-proxy
cwrsync
canvg
telepat
phpldapadmin
java-security
mass-assignment
apache-spark-1.3
nodelist
webmatrix-3
filesplitting
linkedin-jsapi
encryption-asymmetric
trdion2011
parallel-testing
extjs2
synapse
model-driven-development
scringo
workitem
resource-management
wimax
web-notifications
listitem
window-decoration
u2netdk
mbeans
event-receiver
ie-compatibility-mode
updatesourcetrigger
drupal-fivestar
addchild
lxr
web-application-project
windows-identity
pbcopy

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