writing a shell script
hi,
I am writing a script and I need to do something that I don't know how to do it. here it is: I have 2 variable $var1 and $var2 var1=directory/file_name var2=directory/ I need to set a third viarible $var3 to file_name so if I do : echo "$var3" I get on the screen : file_name thanks for your help |
Assuming this is a shell script, you could just insert something like
Code:
cut --delimiter=/ --fields=2 $var1 mj |
sory but I can't get it to work succesfuly :
cut --delimiter=/ --fields=2 echo $var1 echo "$var1" I get this error message : cut: echo: No such file or directory cut: directory/file 1.txt directory/file 2.txt: No such file or directory |
Perhaps you should post your script as it currently stands....
Cheers, mj |
var3=`basename $var1`
Just need to get rid of the spaces ;) Cheers, Tink |
Nice !
Cheers, mj |
var3=`basename $var1`
it works thanks. what is basename for ? I look into the man but didn't understand it (I'm french sory about it ;-) ) |
Quote:
of a fully qualified pathname ... e.g. var1="/usr/X11/lib/fonts/font.dir" basename will return font.dir by default ... Quote:
Cheers, Tink |
thanks a lot.
it is clear in my head now. |
All times are GMT -5. The time now is 10:46 PM. |