Return name of the file in a shell script, without the path?

Get help. Get answers. Let others lend you a hand.

Moderator: Mr_Noodle

I'm using Hazel to run a shell script with this CLI tool to show the name of the file passed to it in a Notification Centre message. I use the following code:

MountainNotifier com.google.Chrome "Download Completed" "$1" ""

How would I get it to show just the name instead of the path to the file as well as the name in the Notification Centre message?
Jono
 
Posts: 26
Joined: Wed May 09, 2012 5:52 am
Location: UK

Jono wrote:I'm using Hazel to run a shell script with this CLI tool to show the name of the file passed to it in a Notification Centre message. I use the following code:

MountainNotifier com.google.Chrome "Download Completed" "$1" ""

How would I get it to show just the name instead of the path to the file as well as the name in the Notification Centre message?



Code: Select all
MountainNotifier com.google.Chrome "Download Completed" $(basename "$1") ""
a_freyer
 
Posts: 631
Joined: Tue Sep 30, 2008 9:21 am
Location: Colorado

That shows just the name, thanks!
I just had to wrap quotes around it as it was only showing the first word in the name.

Thanks again.
Jono
 
Posts: 26
Joined: Wed May 09, 2012 5:52 am
Location: UK


Return to Support