LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-18-2004, 04:05 AM   #1
OrangeLefty
LQ Newbie
 
Registered: Mar 2004
Posts: 13

Rep: Reputation: 0
Removing Text from a Shell String


Hey,

Ive got a very simple question. I have a small script that has a varaible ( $mapfile ) that will return something like foo.map (can be also foobar.map, buzzle.map, shodown.map, blah.map, you get the point)

Now how do i get it to remove the .map part? Perferably by setting a new variable so i dont mess anything currently in the script.

Thanks a bunch.
 
Old 04-18-2004, 05:24 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: Debian
Posts: 2,536

Rep: Reputation: 110Reputation: 110
nomapfile=${mapfile%.map}

e.g.
Code:
#!/bin/sh

files="foofoo.map barbar.map thing.map foobar.map barfoo.map"

for mapfile in $files ; do
	nomapfile=${mapfile%.map}
	othfile=${nomapfile}.oth
	echo -e "$mapfile\t\t$nomapfile\t\t$othfile"
done
 
Old 04-18-2004, 11:08 PM   #3
OrangeLefty
LQ Newbie
 
Registered: Mar 2004
Posts: 13

Original Poster
Rep: Reputation: 0
Thank you very much, it worked without any problems
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find and change a specific text in a text file by using shell script Bassam Programming 1 07-18-2005 07:15 PM
how to modify a text file or a string in shell programming luckyvietman Programming 5 07-12-2005 05:08 PM
problems in removing white spaces from string of text monil Programming 7 03-08-2005 11:28 AM
Removing '\r' from a string beep Programming 5 01-27-2005 07:13 AM
Removing spaces from string qcoder Programming 3 07-05-2004 12:35 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 02:26 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration