Solved

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

Posted on 2014-04-06
4
545 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
Comment Utility
echo 'fourth item' >> a.a

Open in new window


HTH,
Dan
0
 
LVL 10

Assisted Solution

by:santhoshu
santhoshu earned 125 total points
Comment Utility
0
 
LVL 6

Assisted Solution

by:xeroxzerox
xeroxzerox earned 125 total points
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
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…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

772 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