Solved

How do I add a line of text to the end of a file

Posted on 2014-04-06
4
575 Views
Last Modified: 2014-04-06
I am using RHEL.  If I have a file a.a, and it contains the following:

first item
second item
third item

... and I want to add a line at the end of the file, and perform something like

concatenate  a.a  "fourth item"

and the result would look something like

first item
second item
third item
fourth item

(Note, this will requiree a CR)

What command would I use to perform this
0
Comment
Question by:Anthony Lucia
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 35

Assisted Solution

by:Dan Craciun
Dan Craciun earned 125 total points
ID: 39981526
echo 'fourth item' >> a.a

Open in new window


HTH,
Dan
0
 
LVL 10

Assisted Solution

by:santhoshu
santhoshu earned 125 total points
ID: 39981537
0
 
LVL 6

Assisted Solution

by:xeroxzerox
xeroxzerox earned 125 total points
ID: 39981553
hi,
various option you can use like..

$ sed -i '$ a\this is line 2 without redirection' test
then see file without opening
# cat test

2nd one
#echo 'hello' >> file.txt
0
 
LVL 17

Accepted Solution

by:
bigeven2002 earned 125 total points
ID: 39981555
Hello,

I typically use VI to edit text files.
vi a.a

Open in new window

In VI, it opens as read-only.  To edit, press I for insert.  Then it becomes editable.  Place the cursor at end of line 3, then press Enter for new line.  Add desired text.  Then press Shift+; to call a command line at bottom of file, then type wq and press Enter to save and close file.  "wq" stands for write;quit.

If you want to familarize yourself with all of VI's commands, see this link:

http://glaciated.org/vi/
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question