LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-29-2010, 06:52 PM   #1
Gary Baker
Member
 
Registered: Mar 2007
Location: Whitsett,NC
Distribution: Slackware 14.1 and MINT 17.1
Posts: 105

Rep: Reputation: 3
Bash Function Problem


This is my second post for Bash Function Problem. Thanks to all who help!


I have taken into count spacing of functions as a reason for not working. Can you get this function to work on your machine?

quickfind () { find . -maxdepth 2 -iname "*$1*" }

It does not print the retired output but find . -maxdepth 2 -iname "*$1*" does work. What is wrong?

I have gotten both to work thanks to all who helped

Gary

quickfind () { find . -maxdepth 2 -iname "*$1*" ; }

If I run this from the commandline I don't get an error but no output?
I am not running this inside a script but from the commandline.

I want to be able to run any function () from the commandline.

Thanks to all who helped I got it to work!

I have more functions that I can't get to work?

tt () { tree -pFCfa . | grep "$1" | less -RgIKNs -P "H >>> " }

Thanks to all who helped I got it to work!

Last edited by Gary Baker; 11-01-2010 at 01:39 PM.
 
Old 10-29-2010, 07:05 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556Reputation: 556
Hi there,

You haven't said what evidence you have that it doesn't work, so it's hard to tell precisely what the problem is, but I have a guess or two.. The function works fine for me.

Are you running this just in the shell, or as part of a script? In either/both cases, is the working directory the same? If not, then the find command will be looking in a different "." directory.

What about the $1 ? If this is part of a script, then $1 is going to be the positional parameters that were passed to the script itself. Inside the function, it is a different $1 because functions have their own set of positional parameters. So, are you passing the filename to the function, if it's part of a script?
 
1 members found this post helpful.
  


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
[SOLVED] Bash Function Problem Gary Baker Linux - Software 3 10-26-2010 02:02 PM
[SOLVED] Problem with getting array from function (bash) DrLove73 Programming 19 09-25-2009 07:07 AM
bash function calling problem arashdx Linux - Newbie 1 03-10-2009 03:42 PM
Bash: Problem to run a function in Case mitramcc Linux - Newbie 1 02-12-2009 02:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 04:23 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