06-06-2004
by minor changes i mean adapting it for my script and changing for example "FILE=$(basename program)" to "FILE=$(basename $program)"
I have also encountered another problem on closer investigation.
$0 which provides the input for dirname and basename does not put a \ before spaces which dirname especially doesn't like.
the only way around this that i can think of is to use something like;
no1=$($0 | awk '{print $1}')
no2=$($0 | awk '{print $2}')
no3=$($0 | awk '{print $3}')
execpath=$(echo $no1\ $no2\ $no3)
exedir=$(dirname $execpath)
exefile=$(filename $execpath)
however this would require me to know how many spaces exactly will be in the files path.
This is starting to look complex.
What do i do?
9 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
so here is my path:
/usr/bin:/bin:/usr/sbin:/sbin:/Users/a:/usr/local/bin:/usr/X11/bin
how would I remove only the "a" or name string within it?
any help appreciated (7 Replies)
Discussion started by: cleansing_flame
7 Replies
2. Shell Programming and Scripting
Hi,
I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me.
If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in
Thanks in advance...!!! (3 Replies)
Discussion started by: aswani_n
3 Replies
3. Shell Programming and Scripting
Hi
I have two path as follows
system/console/bin/code/sample/testfile.txt
system/console/bin/database/files/new/dbfile.txt
I need the output as
code/sample in first case
database/files/new in second case
That is I am omitting system/console/bin and the filename(s) in both... (2 Replies)
Discussion started by: ssuresh1999
2 Replies
4. Shell Programming and Scripting
Hi
I have written a script .The script runs properly if i write sql queries .But if i use PLSQL commands of BEGIN if end if , end ,then on running the script the comamds are getting printed on the prompt .
Ex :temp.sql
After connecting to the databse at the sql prompt i type... (1 Reply)
Discussion started by: isha_1
1 Replies
5. UNIX for Dummies Questions & Answers
I have a variable name storing a directory path
set dirpath = /home/chrisd/tatsh/branches/terr0.50/darwin
I want to ensure there is always a "/" at the end, and if there are more than one "/", that I reduce it to just one.
---------- Post updated at 08:16 AM ---------- Previous update was... (3 Replies)
Discussion started by: kristinu
3 Replies
6. Solaris
Hi all,
I have written the following program and run on both T5440 and T5220 on same OS version. I found that T5540 server takes more time than T5220. Please find below the details.
test1.cpp
#include <iostream>
#include <pthread.h>
using namespace std;
#define NUM_OF_THREADS 20... (17 Replies)
Discussion started by: sanjay_singh85
17 Replies
7. Shell Programming and Scripting
Hi there,
I have the following in my path:
export PATH=/usr/bin:/usr/sbin
But I want to change it programmatically(for the purpose of JBoss automatic(ansible) installs) to:
export PATH=/usr/bin:/usr/sbin:/usr/jdk/jdk1.8.0_60
and after that I need to insert the JAVA_HOME programmatically,... (7 Replies)
Discussion started by: hvdalsen
7 Replies
8. UNIX for Advanced & Expert Users
Currently I am using this laborious command
lvdisplay | awk '/LV Path/ {p=$3} /LV Name/ {n=$3} /VG Name/ {v=$3} /Block device/ {d=$3; sub(".*:", "/dev/dm-", d); printf "%s\t%s\t%s\n", p, "/dev/mapper/"v"-"n, d}'
Would like to know if there is any shorter method to get this mapping of... (2 Replies)
Discussion started by: royalibrahim
2 Replies
9. UNIX for Beginners Questions & Answers
Hello,
I am creating a file with all the source folders included in my git branch, when i grep for the used source, i found source included as relative path instead of absolute path, how can convert relative path to absolute path without changing directory to that folder and using readlink -f ? ... (4 Replies)
Discussion started by: Sekhar419
4 Replies