Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
06-04-2012, 02:17 PM
|
#1
|
|
LQ Newbie
Registered: Mar 2012
Posts: 15
Rep: 
|
Make multiples links with of a script with a PARAMETER
Hi, I try to make several links (of all files in /program/bin/* ) in one location (/usr/local/bin) in one step, to do that I create a script "links"
I try this, and that work
PHP Code:
#!/bin/bash
cd /usr/local/bin/
echo -n "Write the path"
read path
for i in my $path
do
t=${i##*/}
ln -s "$i" "${t%.*}"
done
The problem is when I write the path, it don't work with tab, and I use this script a lot of time and I prefer that it use tab. I want to add a parameter (ex. -path), like this:
Code:
./links -path /program/bin/*
How can I do that?
Thanks
Last edited by Trotel; 06-05-2012 at 09:14 AM.
|
|
|
|
06-04-2012, 03:53 PM
|
#2
|
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,270
|
Try
Code:
#
# 'path' is a poor choice, as it already has a special meaning...
read -e somepath
Google 'bash read tab completion' for several sites with illuminating information.
--- rod.
Last edited by theNbomr; 06-04-2012 at 03:54 PM.
|
|
|
|
06-05-2012, 09:13 AM
|
#3
|
|
LQ Newbie
Registered: Mar 2012
Posts: 15
Original Poster
Rep: 
|
Quote:
Originally Posted by theNbomr
Try
Code:
#
# 'path' is a poor choice, as it already has a special meaning...
read -e somepath
--- rod.
|
Thanks, that work.
|
|
|
|
06-05-2012, 03:10 PM
|
#4
|
|
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,577
|
To expand on the solution, the -e option makes read use the readline library, which is what provides things like tab completion and key shortcuts. See the bash man page for more details on readline (and read).
Quote:
Originally Posted by theNbomr
# 'path' is a poor choice, as it already has a special meaning...
|
Umm, " PATH" has a special meaning. I'm not aware of " path" matching anything in particular. 
|
|
|
|
06-05-2012, 07:27 PM
|
#5
|
|
LQ 5k Club
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,270
|
Yes, my bad. It does have a meaning in c-shell, but of course this is not c-shell. I still wouldn't choose a name with the same spelling in a different case. Some opinions differ.
--- rod.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 04:34 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|