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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how do you parse 1 line at a time of file1 ie. line(n) each line into new file web_developer UNIX for Advanced & Expert Users 4 06-28-2009 01:07 PM
Compare multiple fields in file1 to file2 and print line and next line gillesc_mac Shell Programming and Scripting 7 03-16-2009 06:26 AM
Reading a file line by line and processing for each line sagarparadkar Shell Programming and Scripting 6 03-02-2009 11:59 AM
I need suggestion on problem read a file line by line and do stuff madi3d8 Shell Programming and Scripting 3 01-15-2009 11:33 AM
Deleting Characters at specific position in a line if the line is certain length Cailet Shell Programming and Scripting 10 12-17-2008 02:41 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-26-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
Exclamation how to add ; at the end of last line

hi,
i have file which is having large sql query
eg :

Quote:
select * from tab

i am executing this sql file but now i want to add ; after query on same line
i.e. i should look like

Quote:
select * from tab;
any idea how to achieve it ?
  #2 (permalink)  
Old 09-26-2009
Rhije Rhije is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 103
I am really not sure what you are asking. Could you provide a bit more detail, such as a few lines from the current file (or mock ups), and what you want them to look like ?
  #3 (permalink)  
Old 09-26-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
just wanted to add ; at end of last line !

is it possible via shell script?
  #4 (permalink)  
Old 09-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,928
Yes:

Code:
sed '$s $ ; ' infile > _tmp_ && mv _tmp_ infile

Some sed implementations support in-place editing with the -i switch:


Code:
sed -i '$s $ ; ' infile

And, of course, you can use Perl:


Code:
perl -i.orig -pe's/$/;/ if eof' infile

Bits Awarded / Charged to radoulov for this Post
Date User Comment Amount
09-27-2009 Anonymous sed '$s $ ; ' infile > _tmp_ 666
  #5 (permalink)  
Old 09-26-2009
crackthehit007 crackthehit007 is offline
Registered User
  
 

Join Date: Feb 2009
Location: Pune/Banagalore
Posts: 71
ohk good...does it replaces EOF with ; ?
does it means EOF does not exists in updated file ...then i cant read it right ?
  #6 (permalink)  
Old 09-26-2009
radoulov's Avatar
radoulov radoulov is offline Forum Staff  
addict
  
 

Join Date: Jan 2007
Location: Варна, България / Milano, Italia
Posts: 2,928
Just run the commands and check the file content.
  #7 (permalink)  
Old 09-27-2009
rdcwayx rdcwayx is offline
Registered User
  
 

Join Date: Jun 2006
Posts: 290

Code:
echo "select * from tab" |awk '{print $0";"}'

Reply

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 08:22 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