LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Hello World Script Not Detected Using locate and whereis (https://www.linuxquestions.org/questions/linux-newbie-8/hello-world-script-not-detected-using-locate-and-whereis-886472/)

hitmen 06-15-2011 07:17 AM

Hello World Script Not Detected Using locate and whereis
 
As above.

I read somewhere that shell scripts are not detected because they may be system files.

So how do I detect them.

Noob as I am just doing my hello world program.

Also what is the difference between "ls bin" and "ls /bin"

acid_kewpie 06-15-2011 07:19 AM

Not sure what you're referring to, but that's not true at all. all real files will be indexed by locate. Whereis is a different tool though which searches your $PATH statement for appropriate executable files and manuals, see the manpage for more details.

In general, you should state the problem you actually have, not what you think you need to do to fix it. Why are you where you think you are?

hitmen 06-15-2011 07:22 AM

I created a new script and saved it. locate and whereis does not detect it. However, I can see it using my gnome desktop.

lithos 06-15-2011 08:08 AM

hmm,

it might be that you didn't refresh the DB for 'locate' with "updatedb &"
otherwise you can search for it with find:
Code:

#> find / -name 'yourscriptname' -ls
where / means search from 'root' dir everywhere.


good luck with finding 'yourself' :)

hitmen 06-15-2011 08:14 AM

Do I have to do sudo updatedb every time after I log out?
I remembered I did it quite recently.

SL00b 06-15-2011 08:52 AM

Quote:

Originally Posted by hitmen (Post 4386364)
Do I have to do sudo updatedb every time after I log out?
I remembered I did it quite recently.

No, but you do need to run updatedb after you've created anything you want to be able to find with the locate command later.

Or, you can just set a cron job to run it once a day.

SL00b 06-15-2011 08:55 AM

Quote:

Originally Posted by hitmen (Post 4386293)
Also what is the difference between "ls bin" and "ls /bin"

"ls bin" = "ls ./bin", where the "." indicates the current working directory. So if your home directory is the current working directory, then you'll get a listing of files in /home/<userid>/bin.

"ls /bin" will give you a listing of files in /bin, because that's an absolute path, not a relative one.

acid_kewpie 06-15-2011 09:32 AM

TBH you shouldn't want to do what you're doing. You know where the script is. In your current situation, neither command provides anything you don't already know, so I'd say just forget about it in this *specific* example, it's not important for what you're doing.

chrism01 06-15-2011 07:19 PM

Re updatedb, I believe most distros these days create a cronjob for that at install time; usually set to run about 4am? Have skim through your crontabs; no point in re-inventing the wheel.


All times are GMT -5. The time now is 04:46 PM.