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

Resizing terminal in Emacs
Calling python files directly via command line
Emacs: Terminal vs shell?
fill in password based on var shell script
How to capture expect output using spawn and sftp under solaris
command line : ignore particular file while using wildcards
Escape characters, literal quotations, and variables in KornShell (ksh) script command
Telnet inside a shell script
write into file by changing the file to rtf - awk
Shell script on passing arguments
Boolean in Shell Scripting
conversion of date and time to one number Bash Programming
Need Shell Script to find difference in two files based on first column [closed]
JVM-based scripting language with Maven dependency resolution
Shell script hanging on mail function
AWK in shell script - How to compare and merge TWO files based on a shared key (2 common fields)?

Categories

HOME
fabricjs
kentico
google-cloud-platform
gridview
awk
jmx
socket.io
devise
knitr
switch-statement
limit
polling
missing-data
azure-container-service
nstableheaderview
flume
extjs4.2
fosrestbundle
xcodebuild
filechannel
plink
feathersjs
cfml
backpack-for-laravel
roslyn
flask-sqlalchemy
resourcebundle
itunes
slidetoggle
underscore.js
8051
failover
twiml
testcomplete
corenlp-server
linkedhashmap
jwplayer6
mnist
batching
apiary.io
timing
nohup
amazon-ses
metaprogramming
jvmti
chef-solo
tasm
resolution
xv6
stringtokenizer
claims
openresty
yii2-api
netbeans6.8
activeperl
lightning
reindex
context-switch
edit
bootstrap-tags-input
juice-ui
taocp
node-request
mta
eigenvector
omniauth-facebook
kango-framework
mediametadataretriever
hadoop-partitioning
upx
pushbots
binomial-theorem
evolus-pencil
viola-jones
dulwich
at-job
ssis-data-flow
crowd
administration
appserver
linkedin-jsapi
raygun
trdion2011
live555
mt4j
rolify
dolby-audio-api
android-icons
vfs
correlated-subquery
oracle-enterprise-linux
gobject-introspection
pinch
jqote
resharper-6.0
drupal-fivestar
rowlex
request-headers
silverlight-oob
glui
alsb
escrow
todos
linfu-dynamicproxy
dsoframer

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