Help needed in string manipulation


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help needed in string manipulation
# 1  
Old 09-08-2006
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  
Old 09-08-2006
Code:
old_name=fileone.out
new_name=${old_name%%.out}.txt

# 3  
Old 09-08-2006
why %% is required? I tried without %%, hot an error. Can u explain :-(

-Chanakya
# 4  
Old 09-08-2006
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  
Old 09-08-2006
Hi Vino,
Thanks a lot Smilie
It worked.

Regards,
Amby.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Deleting part of a string : string manipulation

i have something like this... echo "teCertificateId" | awk -F'Id' '{ print $1 }' | awk -F'te' '{ print $2 }' Certifica the awk should remove 'te' only if it is present at the start of the string.. anywhere else it should ignore it. expected output is Certificate (7 Replies)
Discussion started by: vivek d r
7 Replies

2. Shell Programming and Scripting

String manipulation

Hello Could you help with small script: How to split string X1 into 3 string String X1 can have 1 or many strings X1='A1:B1:C1:D1:A2:B2:C2:D2:A3:B3:C3:D3' This is output which I want to have: Z1='A1:B1:C1:D1' Z2='A2:B2:C2:D2' Z3='A3:B3:C3:D3' (5 Replies)
Discussion started by: vikus
5 Replies

3. Shell Programming and Scripting

string manipulation

Hi, I have the followoing details in one file: opt/tra/domain/test/new/filename1 training/ear/help I need to manipulate the string in the following manner: filename1= opt/tra/domain/test/new/filename1 help=training/ear/help last string is the name and equal sign and then... (2 Replies)
Discussion started by: ckchelladurai
2 Replies

4. Shell Programming and Scripting

String Manipulation

Hi, I have a file in the following format 123|shanwer|15DEC2010|bgbh|okok|16JAN3000|okok| I want the following to be in following format 123|shanwer|12\15\2010|bgbh|okok|01\16\3000|okok| SED/PERL/AWK Gurus could you please help me with this? Thanks Shankar (8 Replies)
Discussion started by: Shan2210
8 Replies

5. Shell Programming and Scripting

string manipulation

if I have two string variable, how do I add one to anther. like a= "a" b="b" c=$a+$b but that doesn't work. Is there anyway to solve it.http://www.qtl.co.il/img/copy.pnghttp://www.google.com/favicon.icohttp://www.babylon.com/favicon.icohttp://www.morfix.com/favicon.ico (2 Replies)
Discussion started by: programAngel
2 Replies

6. Shell Programming and Scripting

string manipulation

Hi all, see i have a script that takes few arguments. first one is command we do on file, next is file (mostly txt file with lot of data) third is destination where we do something with data in file. Since im new in scripting, and im learning as i go, i need some hint how to manipulate that... (3 Replies)
Discussion started by: ajemrunner
3 Replies

7. Shell Programming and Scripting

I need help with string manipulation

First of all I am VERY new to this so bare with me and try and explain everything even if it seems simple. Basically I want to read a line of text from a html file. See if the line of text has a certain string in it. copy an unknown number of characters (the last 4 characters wiil be ".jpg" the... (1 Reply)
Discussion started by: c3lica
1 Replies

8. Shell Programming and Scripting

string manipulation

Hi, I have searched this long and hard and don't seem to see another post on this issue. I have two strings each with the same characters but in a different order. String1=”word” String2=”dwor” I want to test them to show their similarity. Unfortunately I can't do a sort so that they will... (9 Replies)
Discussion started by: Cactus Jack
9 Replies

9. Shell Programming and Scripting

String Manipulation

Hi, Suppose I have the following text in a file. ORA-00942: table or view does not exist ORA-01555: snapshot too old: rollback segment number string with name "string" too small Is there any way I can list all the text that starts only with 'ORA-'? Or there any grep command that can... (7 Replies)
Discussion started by: kakashi_jet
7 Replies

10. Shell Programming and Scripting

Help needed in String manipulation

Hi, How to find existance of a string inside another string in unix scripting? Can you give me with an example. I tried this, awk 'BEGIN { print index("peanut", "an") }' But when I used this example, the command prompt was not returning. Only I had to forcibly end by using ^C. Any... (2 Replies)
Discussion started by: ramanan
2 Replies
Login or Register to Ask a Question