The UNIX and Linux Forums  

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 here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
editing ELF file tejuwala Linux 1 05-17-2008 08:22 PM
Editing file rahul303 Shell Programming and Scripting 4 09-23-2007 07:49 PM
Editing File using awk/sed Mohammed Shell Programming and Scripting 4 05-16-2007 08:00 AM
Help with editing file dsravan Shell Programming and Scripting 4 01-31-2007 09:59 AM
File editing using awk rinku11 Shell Programming and Scripting 2 11-23-2006 07:34 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 04-06-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Editing the File using Awk

I have input file that is having below text

098769
178902
234678

I want to modify the input file like below.

'098769',
'178902',
'234678'

Can you please help to get this. I tried but i am not getting this.
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 04-06-2007
Shell_Life's Avatar
Unix/Informix/4GL/SQL
 

Join Date: Mar 2007
Location: Bahia, Brazil
Posts: 695
If you don't want to use awk:
sed -e"s/^/'/;s/$/',/" -e'$s/,//' input_file
Reply With Quote
  #3 (permalink)  
Old 04-06-2007
awk awk is offline
Registered User
 

Join Date: Feb 2007
Posts: 114
awk -v Q=\' 'NR==1{Save0=$0; next}
{ print Q Save0 Q ","; # lag one line so that last line is different
Save0=$0 # store this for next print command
}
END{ print Q Save0 Q }' # at end - dont print the comma
Reply With Quote
  #4 (permalink)  
Old 04-06-2007
Registered User
 

Join Date: Apr 2007
Posts: 2
Thank You Shell Life,

It worked for me. Apprreciate your immediate reply

Thanks Awk for your immediate reply, i did not understand how it will be
working. As i am learning, where should i give the input file or i should
store this as one program and invoke separately. Can you please explain

Thanks in Advance
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 02:15 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0