How can I append a text at end of file after displaying the file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How can I append a text at end of file after displaying the file
# 1  
Old 11-07-2009
How can I append a text at end of file after displaying the file

I have a file "sample.txt" with the content as below:
Hi
This is a Sample Text.

I need a single command using cat which serve the following purpose.

1.display the contents of sample.txt
2.append some text to it
3. and then exit

But, all should be served by a sinle command.Smilie
# 2  
Old 11-07-2009
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Append orginal file date to end of file

Trying to process 1000 or so files. Take original date and append to end of file. Like so: tstpls42.bas tstpls42.bas.Sep-11--2011 Been working along these lines: date=`ll tstpls42.bas |cut -c 46-57 |sed -e 's/]/\-/g' | grep -v '^$'` for i in *.bas ; do j=`ll $i /hpdump/b1 | awk... (1 Reply)
Discussion started by: joeadmin
1 Replies

2. Shell Programming and Scripting

Want it to read the file name and then append date stamp at the end of file?

I was thinking something like for i in `find . -name "*.log.Z"`; do mv $i name.log.Z or something like that? (3 Replies)
Discussion started by: xgringo
3 Replies

3. Shell Programming and Scripting

Append the text file with comma at the end of every word

Hi folks, Using shell, I am trying the append comma to every line of text. the requirement is like, I have to open the txt file in unix and read line by line and should add comma at the end of every word to make it single line txt file ------- abc@gmail.com bcd@gmail.com... (7 Replies)
Discussion started by: giridhar276
7 Replies

4. Shell Programming and Scripting

Append text from one file to another based on a search from the end of a document

Hi all, I have output files that are all text files with various different extensions. So, if I submit the input file "job_name.inp", when it finishes I get an output file "job_name.dat". A typical input file looks something like this: $CONTRL SCFTYP=RHF RUNTYP=ENERGY MAXIT=199 MULT=1... (4 Replies)
Discussion started by: marcozd
4 Replies

5. Shell Programming and Scripting

append some text message at the end of the file

Hi All, Please tell me how to append some text message at the end of the file. "File too large to view" example: xyz.log contains hhhhhhhhhhh hhhhhhjjjjjjjjj jjjjjjjjjjjjjjjjjjjjjj "File too large to view" Please advice (3 Replies)
Discussion started by: rajeshorpu
3 Replies

6. Shell Programming and Scripting

Append text at end of the first line in a file

Hi I need to append some text @ end of the first line in a file. like myfile.txt list = a,b,c list.a=some.. I give the arg "d" . now it append at end of first line list=a,b,c,d list.a=some... Please help me out this (7 Replies)
Discussion started by: catgovind
7 Replies

7. Shell Programming and Scripting

Append to end of each line of file without a temp file.

Hello I am trying to append an incrimenting number to the end of each line I have it working with a temp file. But I want to do this without a temp file. a=1 cat "file" | while read LINE do echo "$LINE, $a" >> filewithnumbers a=`expr $a + 1` ... (4 Replies)
Discussion started by: rorey_breaker
4 Replies

8. UNIX for Dummies Questions & Answers

How to append a file extension to end of a file name??

Hi, I have a .txt file and it contains some file names.I want to append .gz extension to all the file names that are present within the .txt file. Input. aa.bb.Mar-20-2007 aa.cc.Mar-20-2007 Output aa.bb.Mar-20-2007.gz aa.cc.Mar-20-2007.gz Please help me with this command. ... (10 Replies)
Discussion started by: kumarsaravana_s
10 Replies

9. Shell Programming and Scripting

Append a field to the end of each line of a file based on searching another file.

Hi All, I have two comma separated value(CSV) files, say FileA and FileB. The contents looks like that shown below. FileA EmpNo,Name,Age,Sex, 1000,ABC,23,M, 1001,DES,24,F, ... (2 Replies)
Discussion started by: ultimate
2 Replies

10. Shell Programming and Scripting

echo, append to end of file

I need the line printed with echo to append to eof of to exactly line, am i able to do that? i mean echo "sysctl -w lalala=1" > to end of file /etc/sysctl.conf or to the 21st line, if the line exist, open new line and insert text there. Thx.maybe i'm in wrong topic but anyway... (2 Replies)
Discussion started by: hachik
2 Replies
Login or Register to Ask a Question