LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-03-2015, 01:39 PM   #1
jmgibson1981
Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Ubuntu LTS
Posts: 122

Rep: Reputation: Disabled
Isolate part of a path (BASH)


I'm looking for a way to isolate part of a path, the length of the path could be anything. Basically take

Code:
/data/jason/bin
and isolate just bin from that. would have to work with different lengths though.

Code:
/spinner/users/jason/failbox/bin
again need to isolate just bin without the leading /. How would I go about that?
 
Old 10-03-2015, 01:44 PM   #2
millgates
Member
 
Registered: Feb 2009
Location: 192.168.x.x
Distribution: Slackware
Posts: 840

Rep: Reputation: 380Reputation: 380Reputation: 380Reputation: 380
Have you tried
Code:
basename $path
 
1 members found this post helpful.
Old 10-03-2015, 01:45 PM   #3
jmgibson1981
Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Ubuntu LTS
Posts: 122

Original Poster
Rep: Reputation: Disabled
I just discovered that when you posted . Thank you.
 
Old 10-03-2015, 04:45 PM   #4
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,244

Rep: Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684Reputation: 2684
Also:
Code:
${path##*/}
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Bash shell scripting Part I & Part II onebuck Linux - General 16 03-06-2016 10:10 AM
Moving files from parent path to multiple child path using bash in efficient way Karthikgv417 Programming 5 05-03-2015 11:05 PM
bash script path issue - how to pass a path as a string to a variable PiNPOiNT Programming 5 04-17-2009 06:48 PM


All times are GMT -5. The time now is 01:54 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration