LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy
User Name
Password
Puppy This forum is for the discussion of Puppy Linux.

Notices


Reply
  Search this Thread
Old 12-04-2014, 09:02 PM   #1
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Rep: Reputation: 169Reputation: 169
Replaceable parameter


I am trying to use a replaceable parameter so I can just type

search.sh Blank.sh for example.

I guess I am not using it correctly.

Code:
find / -name $1
 
Old 12-06-2014, 08:01 AM   #2
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
If the contents of search.sh contains the find statement $1 reflects the first parameter in the search call.

But I must say the information you provide is minimal. You don't post t he contents of you script file. You don't tell why you assume you don't use it correctly.

If you want assistance you should show at least the effort to post correctly. If that is too much effort, why do you expect someone's else effort.

jlinkels
 
Old 12-06-2014, 11:06 AM   #3
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,930

Rep: Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321Reputation: 7321
you need to try the command locate to find files on your host (instead of find)
 
Old 12-06-2014, 01:35 PM   #4
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by jlinkels View Post
If the contents of search.sh contains the find statement $1 reflects the first parameter in the search call.

But I must say the information you provide is minimal. You don't post t he contents of you script file. You don't tell why you assume you don't use it correctly.

If you want assistance you should show at least the effort to post correctly. If that is too much effort, why do you expect someone's else effort.

jlinkels
I feel that you are being critical.

I am seeking help.
 
Old 12-07-2014, 01:22 PM   #5
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
#!/bin/bash
# Faster than P_Find
# Find files using a replaceble parameter
# ex. Find_File.sh Blank.sh
#
# Linux Puppy 5.9.3
# SiegeWorks 2014 A.P.K.
#
clear
find / -name $1
 
Old 12-07-2014, 04:20 PM   #6
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
For me it works and the file is shown as searched for. Where does it not for you? How do you call the script?

jlinkels
 
Old 12-07-2014, 06:00 PM   #7
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
I do not understand this statement.

Quote:
Where does it not for you?
How do you call the script?

I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.

Last edited by Fixit7; 12-07-2014 at 06:01 PM.
 
Old 12-07-2014, 06:13 PM   #8
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
I don't think anyone was being critical, but I agree that it is not at all clear what problem you are seeking help with.

Perhaps an example would help, if you could show us how you call the script and what the result is, and why you think it is not correct.

For example...

Code:
Find_File somefilename

No such file or directory
 
Old 12-07-2014, 07:23 PM   #9
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by Fixit7 View Post
I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.
Code:
jlinkels@donald-pc:/tmp$ ./find_file.sh saints_marching.wav
<snip>
find: `/home/lost+found': Permission denied
/home/jlinkels/saints_marching.wav
find: `/mnt/homeserv/data/music/lost+found': Permission denied
<snip>
Quote:
Originally Posted by Fixit7 View Post
#!/bin/bash
# Faster than P_Find
# Find files using a replaceble parameter
# ex. Find_File.sh Blank.sh
#
# Linux Puppy 5.9.3
# SiegeWorks 2014 A.P.K.
#
clear
find / -name $1
I am amazed that you have named your file Find_File.sh and are able to call it with Find_File without the .sh extension.

jlinkels
 
1 members found this post helpful.
Old 12-08-2014, 12:00 AM   #10
SAbhi
Member
 
Registered: Aug 2009
Location: Bangaluru, India
Distribution: CentOS 6.5, SuSE SLED/ SLES 10.2 SP2 /11.2, Fedora 11/16
Posts: 665

Rep: Reputation: Disabled
Quote:
Originally Posted by Fixit7 View Post
I do not understand this statement.



How do you call the script?

I put my script directory in my path, so all I do is

Find_File <name of file>

(No .sh extension is needed nor a ./ prefix )

Later I will improve the script by adding more parameters.

No not that :

Code:
[dracula on client ~] $ cat testaprog.sh
#!/bin/bash
[ ! $1 ] && {
echo -e "err!! no input given"; exit 1; } || echo -e "doing something with $1";
[dracula on client ~] $

[dracula on client ~] $ ./testaprog.sh
err!! no input given

[dracula on client ~] $ ./testaprog
-bash: ./testaprog: No such file or directory

Last edited by SAbhi; 12-08-2014 at 12:06 AM. Reason: re-arranging
 
Old 12-08-2014, 09:29 AM   #11
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Quote:
Originally Posted by jlinkels View Post
Code:
jlinkels@donald-pc:/tmp$ ./find_file.sh saints_marching.wav
<snip>
find: `/home/lost+found': Permission denied
/home/jlinkels/saints_marching.wav
find: `/mnt/homeserv/data/music/lost+found': Permission denied
<snip>
I am amazed that you have named your file Find_File.sh and are able to call it with Find_File without the .sh extension.

jlinkels
It's simple. Add your script directory to the path in /etc/profile.

There are many sripts on your system which have no extension.

When the kernel sees !#/bin/bash/ then it knows that it is a script.

Last edited by Fixit7; 12-08-2014 at 09:37 AM.
 
Old 12-08-2014, 09:33 AM   #12
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Astrogeek,

I posted that my script is working. Maybe it is the lang
uage difference ?
 
Old 12-08-2014, 11:10 AM   #13
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Quote:
Originally Posted by Fixit7 View Post
It's simple. Add your script directory to the path in /etc/profile.
There are many sripts on your system which have no extension.
When the kernel sees !#/bin/bash/ then it knows that it is a script.
Executing a file called Find_File.sh by calling it without the .sh extension is something I have to see yet.

jlinkels
 
Old 12-08-2014, 12:01 PM   #14
Fixit7
Senior Member
 
Registered: Mar 2014
Location: El Lago, Texas
Distribution: Ubuntu_Mate 16.04
Posts: 1,374

Original Poster
Rep: Reputation: 169Reputation: 169
Would you like me to post my console output ? :-)
 
Old 12-08-2014, 12:57 PM   #15
astrogeek
Moderator
 
Registered: Oct 2008
Distribution: Slackware [64]-X.{0|1|2|37|-current} ::12<=X<=15, FreeBSD_12{.0|.1}
Posts: 6,269
Blog Entries: 24

Rep: Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196Reputation: 4196
Quote:
Originally Posted by Fixit7 View Post
Astrogeek,

I posted that my script is working. Maybe it is the lang
uage difference ?
Yes it must be language barrier.

So, if it is working, do you have a question or were you only sharing your script?

Quote:
Originally Posted by Fixit7 View Post
Would you like me to post my console output ? :-)
Yes, that might help us all to understand what you are asking or telling us.
 
  


Reply



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
Electric Shaver with Replaceable Batteries? hydraMax General 6 01-11-2012 11:15 PM
shell getopts: opt w/ optional parameter is taking next opt as its parameter! GrapefruiTgirl Programming 22 10-27-2010 06:00 AM
LXer: No Operating System is Replaceable LXer Syndicated Linux News 0 07-27-2010 02:10 PM
linux bash - how to use a dynamic parameter in shell parameter expansion expression nickleus Linux - General 2 08-21-2006 04:54 AM
Is my CPU replaceable/upgradeable (not Linux-specific) nickj6282 General 2 05-08-2006 06:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Puppy

All times are GMT -5. The time now is 09:54 AM.

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