LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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

Reply
 
Search this Thread
Old 06-04-2012, 02:17 PM   #1
Trotel
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Rep: Reputation: Disabled
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 -
"Write the path" 
read path 
for i in my $path 
do 
t=${i##*/} 
ln -"$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.
 
Old 06-04-2012, 03:53 PM   #2
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
Old 06-05-2012, 09:13 AM   #3
Trotel
LQ Newbie
 
Registered: Mar 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by theNbomr View Post
Try
Code:
#
#  'path' is a poor choice, as it already has a special meaning...
read -e somepath
--- rod.
Thanks, that work.
 
Old 06-05-2012, 03:10 PM   #4
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949Reputation: 1949
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 View Post
# '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.
 
Old 06-05-2012, 07:27 PM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,395
Blog Entries: 2

Rep: Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903Reputation: 903
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.
 
  


Reply

Tags
link, links, parameter, script


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
Make multiples links with a parameter (Bash & Perl) Trotel Programming 5 06-06-2012 10:30 AM
read in parameter and make it as keyboard output chi99 Linux - General 3 04-19-2011 09:49 AM
[SOLVED] Trying to write a command line script that will make symbolic links dave247 Programming 5 10-21-2010 12:24 PM
How to run same script on multiples servers s_linux Linux - General 1 07-21-2009 02:52 PM
need help to make alpha (shape parameter) in mrtg dencar_girl87 Linux - Networking 2 06-23-2008 11:44 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration