locate command alternative,,

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions locate command alternative,,
# 1  
Old 12-13-2010
locate command alternative,,

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

Ok, Im back with another small problem. I created a script (the one posted in the last thread). After some help from some members here all is good. The problem is I made it on by using Putty with my Ubuntu server here at my home. Everything works fine on it. But when I load the script on the server for my class, it complains that it cannot find the command locate. I realize this means that the server probably doesnt have KSH isntalled??

Is there an alternative way to search for a file that will output the full path of the file? I have tried find but it doesnt show the full path.


1. The problem statement, all variables and given/known data:
locate $fname

e.g. locate command not found.


2. Relevant commands, code, scripts, algorithms:



3. The attempts at a solution (include all code and scripts):



4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Lewis And Clark College, Godfrey IL, U.S.A
Mr. Burgess
CNET200

Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 12-14-2010
There is a good chance that yourfile is formatted as a dos document (ie CR/LF on the end). This causes exec to not find the shell because of the extra CR character on the end of you shrek bang line: #!/bin/bash^M

If your server has the dos2unix command you can:
Code:
$ dos2unix locate locate_fixed
$ locate_fixed $fname
...
$ mv locate_fixed locate


If not tr might get the job done for you:
Code:
$ tr -d '\r' < locate > locate_fixed

# 3  
Old 12-14-2010
Also, locate isn't part of ksh, but an independent program, and not necessarily available on all platforms.
# 4  
Old 12-14-2010
Yes pludi, locate belongs to GNU findutils package, in other words it needs to be installed and configured (update of the locate db...) I doubt it possible in this case...So our friend will have to either create a db similar (good luck...) or resolve his issue by removing the specific argument used in find and look for a workaround for replacement
# 5  
Old 12-14-2010
Just to let everyone know I ended up just using
Code:
find / $fname -ls

Not exactly what I wanted but it will get the job done.

Thanks again for all the help!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Alternative to cp command

Good Afternoon, I'm backing up a folder from one NAS to another using a unix script using cp. Its a lot of files and takes several days to complete. Most of the files don't change from week to week. Is there a command that would be quicker? Also note, the backup needs to be ready-to-use in... (5 Replies)
Discussion started by: Stellaman1977
5 Replies

2. Shell Programming and Scripting

Maxdepth command not working in AIX.Need alternative solution for this command

Hi All, I am trying to select 30 days older files under current directory ,but not from subdirectory using below command. find <Dir> -type f -mtime + 30 This command selecting all the files from current directory and also from sub directory . I read some documention through internet ,... (1 Reply)
Discussion started by: kommineni
1 Replies

3. AIX

Alternative command for topas

hi, I need alternative command for topas to check cpu %, i tried with ps but their is lot of diffference between the outputs of two commands... Thanks (3 Replies)
Discussion started by: sumanthupar
3 Replies

4. Shell Programming and Scripting

Locate command not working

HI when ever i type the locate command it is saying like below warning: locate: warning: database /var/lib/slocate/slocate.db' is more than 8 days old i am using Linux . version is as follows... $ uname -a Linux abc.abc.com 2.6.9-89.35.1.ELhugemem #1 SMP Tue Jan 4... (3 Replies)
Discussion started by: ptappeta
3 Replies

5. AIX

Locate command

Hello to all, Can I use the "locate" command on AIX 5.3 like on Linux. If yes what packages should I install and where can I find them. Thanks, Enid (9 Replies)
Discussion started by: enux
9 Replies

6. UNIX for Dummies Questions & Answers

Locate command in encrypted home

Hi! I have some files that I want to locate using the locate command in terminal, but my home folder is encrypted using FileVault from Mac OS X 10.6. Any idea how can I locate them, being my home encrypted? (8 Replies)
Discussion started by: tirwit
8 Replies

7. HP-UX

Locate command in HP-UX and Solaris

Previously i worked on linux now i am working on HP-UX and solaris ... I am not able to use Locate command(command not found) in HP-Ux and solaris. Suggest me some options to use locate (6 Replies)
Discussion started by: girija
6 Replies

8. UNIX for Dummies Questions & Answers

alternative for head command

Hi friends,I am new to unix and this is really a dummy question.but please help me out. How to simulate head command without using head command??? also tail command too,also more command. it is given as a homework to do....please tell me how to do (2 Replies)
Discussion started by: nikhilneela
2 Replies

9. Shell Programming and Scripting

locate command doubt !!!

Hello, I want to search for a file/directory named "abc" which is located anywhere in the given unix system. I am using the command :- But the problem is that this is giving me all combinations of files with have 'abc' in their name. But can I know the option to be used to get the location... (5 Replies)
Discussion started by: nsharath
5 Replies

10. UNIX for Dummies Questions & Answers

command locate.

Hi, I am aware of the command locate/slocate. But when I try to search the file which is located in /tmp. Its not able to get it. I tried by updating the database also with the command updatedb. Is there any consern that the command 'locate' dont check /tmp??? And I knew that locate is the... (5 Replies)
Discussion started by: praveen_b744
5 Replies
Login or Register to Ask a Question