The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
script to monitor process running on server and posting a mail if any process is dead pradeepmacha Shell Programming and Scripting 12 10-17-2008 12:08 AM
Need to get pid of a process and have to store the pid in a variable samudha UNIX for Dummies Questions & Answers 7 08-05-2008 12:24 AM
Killing of a process and send a mail if the process doesnot come up within 2 minutes Prince89 Shell Programming and Scripting 1 02-15-2008 04:10 PM
striping the text in AWK yoyo123 Shell Programming and Scripting 3 11-08-2007 09:13 AM
how to start a process and make it sleep for 5 mins and then kill that process shrao Shell Programming and Scripting 6 03-27-2007 09:54 AM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 05-08-2006
Registered User
 

Join Date: May 2006
Posts: 3
Striping process variable

Hello. I would like to strip out the process name from the ${0##*\} variable. So that if I have a script named "mytest.script" the variable would be populated with just "mytest" I have tried doing a substring but it doesnt seem to work.

Code:
name=`expr match "${0}" : './*\(/*.\)'`
Doing this gets me "m". I can do it in 2 steps. But I would like to accomplish in 1 if there is a way.

Thank you,
Reply With Quote
Forum Sponsor
  #2  
Old 05-08-2006
Registered User
 

Join Date: May 2006
Posts: 3
Got a little bit closer with
Code:
name=`${0%.*}`
gives me "./my" but now it has the "./" that I want to get rid of.

help...
Reply With Quote
  #3  
Old 05-08-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
use basename

Tried using 'basename' if that is your requirement.
basename /home/user1/new.sh .sh --> gives o/p as new.
Reply With Quote
  #4  
Old 05-09-2006
Registered User
 

Join Date: May 2006
Posts: 3
No I would like to use the ${0} variable to derive the name with out the extension. So if I had a script named thescript.script and i have a variable within the script:
Code:
name=${0##*/}
here i get "thescript.script"
however I want to get "thescript"
Reply With Quote
  #5  
Old 05-09-2006
Playing with Ubuntu Now!
 

Join Date: Oct 2005
Location: Chennai
Posts: 364
re

after you get the thescript.script into 'name'. Do
fname=${name%%.script}
echo $fname --> gives 'thescript'
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 03:47 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0