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
Search, replace string in file1 with string from (lookup table) file2? gstuart Shell Programming and Scripting 9 06-08-2009 07:11 AM
Extracting a string from one file and searching the same string in other files mohancrr Shell Programming and Scripting 1 09-19-2007 04:17 AM
Replace string B depending on occurence of string A hemangjani Shell Programming and Scripting 1 12-05-2006 05:10 PM
appending string to text file based on search string malaymaru Shell Programming and Scripting 1 06-09-2006 09:53 AM
sed problem - replacement string should be same length as matching string. amangeles Shell Programming and Scripting 4 01-11-2006 06:11 AM

Closed Thread
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 11-20-2007
ravi raj kumar ravi raj kumar is offline
Registered User
  
 

Join Date: Dec 2006
Location: hyderabad
Posts: 102
string replacemnet

Hi,:cool:
I have several file names with .sql extension and i need to replace them with .plb extensiom.
ex:p_ebiz_vehlog.sql-->p_ebiz_vehlog.plb.

any idea pls.
cheers
RRK
  #2 (permalink)  
Old 11-20-2007
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798

Code:
for file in *.sql
do
  mv $file "${file%.sql}.plb"
done

  #3 (permalink)  
Old 11-20-2007
ravi raj kumar ravi raj kumar is offline
Registered User
  
 

Join Date: Dec 2006
Location: hyderabad
Posts: 102
hi vino,
The mv command renames the original file.But i dont want to rename the original file.
I want to the original file(.sql) to be remained and i just want to extract the file name without extension
and append the new extension (.plb) and store that new file name in a variable.
cheers
RRK
  #4 (permalink)  
Old 11-20-2007
Kundunni Kundunni is offline
Registered User
  
 

Join Date: Nov 2007
Posts: 18
use cp instead of mv
  #5 (permalink)  
Old 11-20-2007
ravi raj kumar ravi raj kumar is offline
Registered User
  
 

Join Date: Dec 2006
Location: hyderabad
Posts: 102
No man,I dont want the contents.I need onle name of the file.

  #6 (permalink)  
Old 11-20-2007
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
can you please try this one out...............

var1="mysql.sql"
var2=`basename $var1 .sql`
echo $var2 => mysql

this will give you the filename without extension....then go ahead of your own manipulations..........
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 02:17 PM.


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