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
String Manipulation Help shadow0001 Shell Programming and Scripting 4 03-09-2008 04:35 PM
string manipulation Cactus Jack Shell Programming and Scripting 9 02-14-2008 01:14 PM
awk string manipulation zoo591 Shell Programming and Scripting 2 08-09-2006 01:13 PM
string manipulation in C trinath High Level Programming 1 01-23-2006 11:13 AM
Help needed in String manipulation ramanan Shell Programming and Scripting 2 08-24-2005 04:06 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 09-08-2006
haifrancis haifrancis is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
Help needed in string manipulation

Hi,
Im a newbie to UNIX Shell Scripting.

I have a variable "filename" which contains the value "fileone.out". I need help in doing some string manipulation on this variable to change the extension alone and the result should be "fileone.txt", since i need to use this new value to refer another file.

Regards,
Amby.
  #2 (permalink)  
Old 09-08-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

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

Code:
old_name=fileone.out
new_name=${old_name%%.out}.txt

  #3 (permalink)  
Old 09-08-2006
Chanakya.m's Avatar
Chanakya.m Chanakya.m is offline
Registered User
  
 

Join Date: Jan 2006
Location: Bangalore, India
Posts: 55
why %% is required? I tried without %%, hot an error. Can u explain :-(

-Chanakya
  #4 (permalink)  
Old 09-08-2006
vino's Avatar
vino vino is offline Forum Staff  
Supporter (in vino veritas)
  
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,798
Quote:
Originally Posted by Chanakya.m
why %% is required? I tried without %%, hot an error. Can u explain :-(

-Chanakya
Look under 'Parameter Expansion' in man sh for ${parameter%%word}
  #5 (permalink)  
Old 09-08-2006
haifrancis haifrancis is offline
Registered User
  
 

Join Date: Sep 2006
Posts: 2
Hi Vino,
Thanks a lot
It worked.

Regards,
Amby.
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 12:00 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