The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 6 10-25-2008 01:37 PM
"find command" to find the files in the current directories but not in the "subdir" swamymns Shell Programming and Scripting 9 07-22-2008 12:23 PM
unix command/s to find files older than 2 hours in a directory Presanna Shell Programming and Scripting 6 11-20-2007 09:22 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM
how to find a file in UNIX without find command? bluo Shell Programming and Scripting 3 09-25-2003 12:47 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 05-26-2007
jatin.jain jatin.jain is offline
Registered User
  
 

Join Date: May 2007
Posts: 6
Little bit weired : Find files in UNIX w/o using find or where command

Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same.

Thanks in advance.

Regards
Jatin Jain
  #2 (permalink)  
Old 05-26-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,553
Quote:
Originally Posted by jatin.jain
Yes , I have to find a file in unix without using any find or where commands.Any pointers for the same would be very helpful as i am beginner in shell scritping and need a solution for the same.

Thanks in advance.

Regards
Jatin Jain
the only reason i guess you can't use find is you might be doing homework. but nevertheless .. if you can't use find, use locate? the other way is to use ls with -R option.

Last edited by ghostdog74; 05-26-2007 at 06:00 AM..
  #3 (permalink)  
Old 05-26-2007
jatin.jain jatin.jain is offline
Registered User
  
 

Join Date: May 2007
Posts: 6
Hi Ghost,
i tried using ls but how to do it recursively ls -r ?. It dint work for me
i will show u a snippet of my script

#!/bin/sh
echo $1 #display the input entered
c=$1
ls -l $c | awk `(if(NR>0) pwd)` # usinf ls command and awk i m trying to get those records and print its path,pwd is not working there
  #4 (permalink)  
Old 05-26-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,553
assuming you know the file name
Code:
#!/bin/sh
ls -lR / | awk -v filename="$1" '/^\//{ dir=$0} 
                /^-/{ if ( $9 == filename ) { 
		       print "Found " filename " in "dir
		      }
		
		}'

Last edited by ghostdog74; 05-26-2007 at 06:28 AM..
  #5 (permalink)  
Old 05-26-2007
jatin.jain jatin.jain is offline
Registered User
  
 

Join Date: May 2007
Posts: 6
awk: syntax error near line 1
awk: bailing out near line 1
whts this
  #6 (permalink)  
Old 05-26-2007
ghostdog74 ghostdog74 is offline Forum Advisor  
Registered User
  
 

Join Date: Sep 2006
Posts: 2,553
what did you do? show your code.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:11 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0