Striping process variable


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Striping process variable
# 1  
Old 05-08-2006
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,
# 2  
Old 05-08-2006
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...
# 3  
Old 05-09-2006
use basename

Tried using 'basename' if that is your requirement.
basename /home/user1/new.sh .sh --> gives o/p as new.
# 4  
Old 05-09-2006
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"
# 5  
Old 05-09-2006
re

after you get the thescript.script into 'name'. Do
fname=${name%%.script}
echo $fname --> gives 'thescript'
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Export variable, as a background process

Have a script where I need to wait for a process to run, but from that process I want to capture the row count. Script I have so far (easier than explanation): echo "Start" export NUMROWS=`td "select * from dbc.database" 2> /dev/null | grep "Query completed" | sed -e 's/.*Query... (7 Replies)
Discussion started by: Cranie
7 Replies

2. Shell Programming and Scripting

Get PID of a process into a variable

Hi All, I need to get the PID of a process which i ran in background into a variable echo $! gives me the PID of last background process but how to get this into a variable so that i can use "wait" command later in the script to make sure that this background process was done var = `echo... (5 Replies)
Discussion started by: firestar
5 Replies

3. UNIX for Advanced & Expert Users

How to get the process id in to variable?

Dear Experts, Pl help me to fix this i am trying to unmount the all the file systems in VG, Once unmounted vary off the VG. I have written the script to do that it works fine when none of user or process id holds it but if in use it says resource is busy and can't unmount. even i used... (2 Replies)
Discussion started by: nmadhuhb
2 Replies

4. Shell Programming and Scripting

Capture Process with highest CPU% in Variable

I am trying to capture the process on a red hat linux system with the highest cpu utilization into a variable. I have been playing with ps command but really do not think I am making the correct progress. For instance: top - 09:01:16 up 63 days, 18:29, 2 users, load average: 0.39, 0.49, 0.48... (5 Replies)
Discussion started by: jaysunn
5 Replies

5. Shell Programming and Scripting

sed - striping out html tags

I have pasted the contents of a log file (swmbackup.wrkstn.1262071383.sales2a) below: Workstation: sales2a<BR Vault sales2a-hogwarts will be initialized.<BR <font color="red"There was a problem mounting /mnt/sales2a/desktop$ </FONT<BR <font color="red"There was a problem mounting... (4 Replies)
Discussion started by: bigtonydallas
4 Replies

6. Shell Programming and Scripting

Reading a file with while into variable and using in another process

I would appreciate some help, please. I have a file cutshellb.txt, which contains four report names (but it could be any number from 1 to x. The report suffix is not necessarily consecutive: report3785 report3786 report3787 report3788 I have a shell script which attempts to read the... (3 Replies)
Discussion started by: Dicloflex
3 Replies

7. Windows & DOS: Issues & Discussions

"Striping" the background of an Rxvt/Urxvt window in Cygwin

To get this: https://www.unix.com/members/silversleevesx-albums-incidental-shot-glass-picture127-termshot-rxvt-rootless.png out of Cygwin's rxvt, you have to tweak your /cygwin/etc/x11/app-defaults/rxvt file, which is here:... (0 Replies)
Discussion started by: SilversleevesX
0 Replies

8. Shell Programming and Scripting

Finding PID of a process using variable substituition

Hi All, Am copying mulitple files in a directory in names File0,File1,File2 etc. I need to print separately the PID of these copies using File names. for((i=0;i<5;i++)) do mypid=`ps aux | awk '/File$i/ && !/awk/ { print $2 }'` echo PID is $mypid done It printed nothing. Thinking... (6 Replies)
Discussion started by: amio
6 Replies

9. Shell Programming and Scripting

echo is striping mah quotes

As the title says, echo is striping my quotes and I need them. echo "<?xml version="1.0" encoding="ISO-8859-1"?>" returns: <?xml version=1.0 encoding=ISO-8859-1?> Obviously, echo "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>" returns the result I need: <?xml version="1.0"... (3 Replies)
Discussion started by: s_becker
3 Replies

10. Shell Programming and Scripting

striping the text in AWK

hello, what I have: --- lots of text bla bla bla PATCH MANAGEMENT AND SOFTWARE UPDATES - EXTERNAL Risk Severity: High Area: External Network Relative Rating: Medium lots of text bla bla bla WIRELESS AP Risk Severity: High Area: External Network Relative Rating: Poor ... (3 Replies)
Discussion started by: yoyo123
3 Replies
Login or Register to Ask a Question