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

MSAccess VBA Shell Command - Max Length?
How to compute spectrum using awk or shell scripting?
Shell command to count lines in a file
gitlab ci false passed
How compute trend using awk?
Chrome shell script
windows equivalent of this shell script
Find command not working with -mtime and -daystart parameter in linux-bash
How to get docker 'objects' completion on mintty-bash from git for windows
How can I export an environment variable in a Makefile? [duplicate]
Finding existence each string in file1 in another file
Challenge in setting up the script which connects to multiple servers as an autosys job
Run program over pty
Unix, Sort by number
Shell: How do I run a shell script from a directory above on multiple files
How to count the number of artefacts in nexus repository manager OSS 3.2.1 in terminal

Categories

HOME
android
shell
batch-file
httparty
deep-learning
linkedin
datastore
toolbox
jsf-2.2
socket.io
opendj
edge
newrelic
trac
discrete-mathematics
accessibility
angular-dart
code-generation
screen-readers
android-7.0-nougat
digital-signature
sse
replication
microsoft-ocr
jquery-ias
mount
slidetoggle
bioinformatics
postback
dumpbin
gnat-gps
vue-chartjs
fossil
nested-lists
mnist
xajax
apiary.io
sim-card
loading
hackintosh
vmware-fusion
facebook-social-plugins
openal
automapper-5
spring-integration-sftp
rserve
modelsim
payload
flyout
cvxpy
visual-studio-2008-sp1
stripe-connect
myspace
drawstring
wso2developerstudio
xdoclet
qiime
thread-sleep
design-principles
atan2
decimalformat
rpart
keyup
dot.js
post-commit-hook
imagefilter
gii
ss7
kissfft
xml-dsig
alternate
file-not-found
cfcache
gwt-openlayers
windows-phone-8-sdk
jeromq
oocss
server-administration
http-status-code-410
asplinkbutton
bjyauthorize
boost-signals
azman
ilasm
jsr286
hibernateexception
role
user-tracking
jquery-tools
entitydatasource
tournament
luajava
uideviceorientation
interprocess
data-mapping
wysiwym
perl5.12
fault-tolerance
wspbuilder
commercial-application

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile