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

Shell Script to access a remote machine using ssh with usr and pwd both
Increment value of a variable within loop that reads line from file in shell script
print 3 consecutive column after specific string from CSV
Getting parent directory's basename in makefile
what's the below Unix shell mean?
Why am I getting if: Expression Syntax when I try to run this script?
Gnu make: read recipe output into make variable
Creating a CSV file from a text file
how to debug fish script?
Shell Script: Mac, live update counter
File not found error - trying to convert symlinks to regular files
Quickly find and print all files in a folder, recursively, excluding ones from `node_modules` and `.git`
Powershell: Piping values from one function to another
Shell script - search for a line and display line and 3 trailing lines
Best tutorial for Sed and Awk fun [closed]
How do I resolve Syntax error 'for' is not matched?

Categories

HOME
phpword
deep-learning
ecmascript-6
css3
soa
jetty
pearson-correlation
python-multithreading
siddhi
openbugs
dynatrace
zerobrane
azure-iot-hub
fileserver
gmm
pimcore
qliksense
object-storage
beta
stackexchange
pylons
jackson-modules
underscore.js
aws-codecommit
deltaspike
jett
instantiation
joomla2.5
raft
jpad
jvmti
visa
watchface
postgresql-8.4
preloader
dbnull
ssrs-2014
placeholder
angular-http
android-checkbox
vaadin-elements
jboss-4.2.x
gitlist
identification
manova
mongotemplate
modelsim
cup
check-mk
oozie-coordinator
monkey
pybrain
baidu
structuremap4
rocks
visual-studio-2008-sp1
omxplayer
xcode-server
vulcanize
mapinfo
spreadjs
phpwebsocket
cycle2
qbxml
dynamics-nav-2016
decimalformat
zen-cart
extjs-grid
uncompress
haskell-warp
baasbox
user-permissions
public-html
mruby
easyrtc
jama
live555
winginx
authlogic
cfcache
embedded-fonts
away3d
octal
http-status-code-410
josql
oracle-enterprise-linux
kqueue
jquery-tools
creole
clrstoredprocedure
quotation-marks
unattended-processing
cruisecontrol.rb
silent
web-garden
windows-identity
blind

Resources

Encrypt Message