![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| 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 !! |
|
|
||||
| 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 |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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}" : './*\(/*.\)'`
Thank you, |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
Got a little bit closer with
Code:
name=`${0%.*}`
help... |
|
#3
|
|||
|
|||
|
use basename
Tried using 'basename' if that is your requirement.
basename /home/user1/new.sh .sh --> gives o/p as new. |
|
#4
|
|||
|
|||
|
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##*/}
however I want to get "thescript" |
|
#5
|
|||
|
|||
|
re
after you get the thescript.script into 'name'. Do
fname=${name%%.script} echo $fname --> gives 'thescript' |
|||
| Google The UNIX and Linux Forums |