LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-02-2012, 01:47 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
Question export multiple executable paths in a parent directory using regular expressions?


Hello,

I am wondering if there is a way in bash to export an executable path using regular expressions. What I am attempting to do is organize all my executable code into folders but don't want to add each folder to the executable path in my .bash_profile when I create a new one.

Can anyone tell me if it is possible to add something like the following example to my .bash_profile:

Code:
PATH=/home/user/scripts/*;
export PATH
So that I could have execute a file that is possibly located in
Code:
/home/user/scripts/some_other_folder/some_script.pl
 
Old 10-03-2012, 07:13 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,792

Rep: Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306Reputation: 7306
A=(`ls -1s /home/user/scripts/*`)
echo "${A[*]/ /:}"

will print what you need, but will not be checked if there were any files
 
Old 10-03-2012, 09:01 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
How about something like
Code:
export PATH=$( find -regex <your regex> -type d -printf '%p:' )
That ends the list with a trailing : which may not be what you want in which case try something like:
Code:
path=$( find -regex <your regex> -type d -printf '%p:' )
export PATH=${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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular Expressions ziggy25 Linux - Newbie 7 11-05-2007 06:57 AM
remove relative paths using regular expressions Ayman.mashal Programming 1 06-26-2007 04:28 AM
Regular expressions bhuwan Programming 5 02-25-2006 11:07 PM
Unpacking multiple ZIP files (regular expressions) Ariod Linux - Newbie 1 02-24-2006 12:48 PM
Regular Expressions markjuggles Programming 2 05-05-2005 11:39 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 08:28 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
Open Source Consulting | Domain Registration