NEWB Question - BASH COMMAND RESULT for ${0##*/}


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers NEWB Question - BASH COMMAND RESULT for ${0##*/}
# 1  
Old 09-25-2012
Question NEWB Question - BASH COMMAND RESULT for ${0##*/}

This should be extremely simple and someone will probably answer it in .5 seconds. I need to know what:

Code:
VARIABLE=${0##*/}

does? I do not have a shell handy to just try it in. I am reading through some scripts and need to understand this line. Any help is appreciated.

Many thanks!

- Chris
# 2  
Old 09-25-2012
This User Gave Thanks to Corona688 For This Post:
# 3  
Old 09-25-2012
Quote:
Originally Posted by Corona688
See the Advanced BASH Scripting Guide -- String Operations.
Thanks, Corona. Didn't even realize that squiggly braces were for string substitution, it's been a while since I've done shell scripting, just getting back into it. So my understanding is that this should get the current executing script and strip everything off the beginning, leaving just the filename, correct?

Last edited by chrisgoetz; 09-25-2012 at 05:34 PM..
# 4  
Old 09-25-2012
Not necessarily for string substitution. $VAR and ${VAR} amount to the same thing for example. But you can put things inside ${VAR} which do string substitution.

And I think you're right on the money.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Use bash command on awk field and output the result

Hello, I want to run a field from an awk command through a command in bash. For example my input file is 1,2,3 20,30,40 60,70,80 I want tot run $2 thought the command date +%d/%m/%y -d"01/01/15 + $2 days -1 day" and get the output 1,02/01/15,3 20,30/01/15,40 60,11/03/15,80 ... (2 Replies)
Discussion started by: garethsays
2 Replies

2. Shell Programming and Scripting

How i can put the result of a command inside a bash variable?

#!/bin/bash #... for i in `ls -c1 /usr/share/applications` do name="cat $i | grep ^Name= | cut -d = -f2" echo $name #... done Now inside name as output is present: while i want only the result of the command. Ideally i would like obtain that information using only bash ... or... (8 Replies)
Discussion started by: alexscript
8 Replies

3. Shell Programming and Scripting

Newb question about getting a word from a text file

Hi everyone. I am new to shell scripting and have been looking at quite a few web pages to try and figure this out, but to no avail. What I am trying to do is get a value from a text file that contains a paragraph of information.. Something similar too: Welcome to random script You are... (1 Reply)
Discussion started by: elemenopee
1 Replies

4. Shell Programming and Scripting

Newb with While loop question

My first post here.... I have a few years exp with linux distros and some very basic Python..Ive been intent on learning shell scripting the last few weeks. Please excuse my crude efforts. I am running a program that takes network data containing US city names in plain text. I am TRYING to... (7 Replies)
Discussion started by: dddkkk
7 Replies

5. Shell Programming and Scripting

help newb at linux and bash need numeric script sort

I am trying to setup to automatically import a series of mysql database files. I am doing manually now and its a royal pain. All the sql files are sequentially numbered in a format of 4 numbers underscore text with spaces replaced by underscores. example: There are 3 databases each setup... (1 Reply)
Discussion started by: dlm1065
1 Replies

6. Shell Programming and Scripting

help a newb with cut command

Ok I'm working on this school assignment and I'm sure there is a simple solution to this but I can't find it anywhere. The scenario is that I have to write a script with a menu and stuff like that. One of the options has to be to generate a sales report from a database called items.dat. Items.dat... (4 Replies)
Discussion started by: silveronetrx
4 Replies

7. Shell Programming and Scripting

Another newb question: how to use test for zero-length string ?

Assume $x equals "". If I try: if test -n $x I get the "Expression syntax" error. It works in Linux but not in unix bash. In unix bourne I get "test: argument expected" (4 Replies)
Discussion started by: lumix
4 Replies

8. Shell Programming and Scripting

Newb scripting question, I get the error script not found

This is probably a really simple problem, but goes easy on me I'm still a newb. The problem I have is that a script (we'll call it script.script) I edited won't run for some reason, I get the error "ksh: script.script: not found" The location of my script is as follows: /home/users/arkitech ... (3 Replies)
Discussion started by: Arkitech
3 Replies

9. UNIX for Dummies Questions & Answers

Newb question

I don't even know if this should go here but I just would like to know what this means: d0e45878043844ffc41aac437e86b602 I know absolutely nothin' about UNIX, and I found this in a SQL table in a board I run. Someone please tell me what that is in "normal" mode. Pardon me for my... (4 Replies)
Discussion started by: daeglin
4 Replies

10. Shell Programming and Scripting

newb shell question

I know this is a total begginer question but what is wrong with this picture. My loop wont loop, it just drops me back to the prompt and gives the error "unary operator expected". Any help would be appreciated. here it is, #!/bin/sh selection= while do cat << MENU 1)List files in... (2 Replies)
Discussion started by: Fokus
2 Replies
Login or Register to Ask a Question