The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to Append a Value to each line of the file dsshishya UNIX for Dummies Questions & Answers 11 03-21-2008 02:48 PM
append a line to the last line in a file subhrap.das UNIX Desktop for Dummies Questions & Answers 5 04-25-2007 09:17 AM
how to append text into a file. beilstwh Shell Programming and Scripting 2 03-06-2007 05:51 PM
using sed to append text to the end of each line Redg UNIX for Dummies Questions & Answers 8 07-26-2006 10:59 AM
Large file need to append to each line r1500 UNIX for Dummies Questions & Answers 1 10-14-2003 10:48 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-01-2008
catgovind catgovind is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
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
  #2 (permalink)  
Old 05-01-2008
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Code:
awk ' NR == 1 { print $0,"sometext" } else { print }' filename
  #3 (permalink)  
Old 05-01-2008
catgovind catgovind is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
Hi madhan

Thanks , when i did this.It will print on the console.But what i need is it changed on the fie.
  #4 (permalink)  
Old 05-01-2008
Franklin52 Franklin52 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2007
Posts: 4,294
Quote:
Originally Posted by catgovind View Post
Hi madhan

Thanks , when i did this.It will print on the console.But what i need is it changed on the fie.
This is the same question you've asked here:

Removing specific lines

Regards
  #5 (permalink)  
Old 05-01-2008
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
As said by Frank

use a temporary file and rename it

or do an in-place edit using sed
  #6 (permalink)  
Old 05-01-2008
catgovind catgovind is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 8
Hi Madhan

Thanks for the help
I found the soln

awk '{if(NR==1){print $0,"sometext"}else{print }}' output_filename > somu
  #7 (permalink)  
Old 05-01-2008
matrixmadhan matrixmadhan is online now Forum Advisor  
Technorati Master
  
 

Join Date: Mar 2005
Location: leaf node in B+ tree
Posts: 2,952
Quote:
Originally Posted by catgovind View Post
Hi Madhan

Thanks for the help
I found the soln

awk '{if(NR==1){print $0,"sometext"}else{print }}' output_filename > somu

My bad

It ran off like that.

Thanks for correcting it

after you redirect; rename it
Code:
mv somu output_filename
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:20 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0