Solved

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

Posted on 2014-04-06
4
549 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
4 Comments
 
LVL 34

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
OpenView NNM: Global Manager to Regional Manager connection fails 7 74
capture pcap with filtered traffic 1 59
nagios remote hosts 9 56
Backup & Restore 3 54
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

813 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now