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
Search files with specfic extention and later search content lovi_v UNIX for Advanced & Expert Users 2 07-14-2008 01:05 PM
Perl: Search for string on line then search and replace text Crypto Shell Programming and Scripting 4 01-04-2008 10:24 AM
Search for a pattern from the result of search boopathi_d Shell Programming and Scripting 3 12-05-2007 09:54 AM
Search for \n Chanakya.m Shell Programming and Scripting 6 07-19-2006 07:57 AM
Advanced Search Problems.. Search by User Name Neo Post Here to Contact Site Administrators and Moderators 1 05-19-2003 01:28 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 04-01-2009
saic saic is offline
Registered User
  
 

Join Date: Dec 2008
Posts: 18
Search

Hi All
Iam new to this unix
i have requirement like below
i will give the inputs i.e file name and path and it search the file, if the file is available it display the file ,if not not found it need to show that file not found on above path.
in addition if the file is not found it should search from all directoreis and if the file found some directory it need show the directory name,if the file is not found it show file not found.
i have wriiten some code as below please give some idea to meet above cretiria.

Code:
#!/bin/bash
echo -e "please enter the file name to search..... \n"
read file_keyword
echo "pleae enter the path where we can search the file...... \n"
read path
echo "searched files are..... \n"
find "$path" -name "*${file_keyword}*" -exec ls -l {} \; | tr -s " " | cut -d" " -f6,7,9


Last edited by Yogesh Sawant; 04-01-2009 at 02:25 AM.. Reason: added code tags
  #2 (permalink)  
Old 04-15-2009
otheus's Avatar
otheus otheus is offline Forum Staff  
Moderator ala Mode
  
 

Join Date: Feb 2007
Location: Innsbruck, Austria
Posts: 1,893
Use this for your find command:

Code:
find $path -name "*${file_keyword}*" -printf "%p\n" || echo "Cannot find filename"

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 05:57 AM.


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