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
file searching... Kaminski Shell Programming and Scripting 1 02-02-2008 07:23 AM
Searching contents of a file thepitzaboy UNIX for Advanced & Expert Users 2 08-30-2007 02:13 PM
searching a file straight_edge Shell Programming and Scripting 4 01-12-2007 09:21 AM
Searching for fields in a file c2b2 UNIX for Dummies Questions & Answers 4 12-12-2006 11:40 AM
Append a field to the end of each line of a file based on searching another file. ultimate Shell Programming and Scripting 2 03-29-2005 11:21 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 01-22-2009
cgk1983 cgk1983 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 6
Dyanamically searching a file

I need a shell script to search different files in a directory i will pass the filename as argument to shell script
Please help me regarding this
  #2 (permalink)  
Old 01-22-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
If it's just for quick and dirty command line and you don't really need a script, you can just do for example:


Code:
find .| grep -E "file1|file2|file3|file4"

  #3 (permalink)  
Old 01-22-2009
cgk1983 cgk1983 is offline
Registered User
  
 

Join Date: Jan 2009
Posts: 6
Need Script for the same

Hi zaxxon,

Thx for u r post i need to do extra business logic in the script but initially first i need to pass the argument (ie filename ) to the script so that i can replace in u r command given

find .| grep -E "file1|file2|file3|file4"

for ex as u said the file1 will be dyanamically given by the user it is not constant so i need a script where in which i can take the argument from the userinput and need to implement the business logic hope u do the needful
  #4 (permalink)  
Old 01-22-2009
Tytalus's Avatar
Tytalus Tytalus is offline Forum Advisor  
echo {1..9}^2\;|bc
  
 

Join Date: Jun 2003
Location: Scotland
Posts: 431
Post what you have attempted so far.
  #5 (permalink)  
Old 01-22-2009
manas_ranjan's Avatar
manas_ranjan manas_ranjan is offline
Registered User
  
 

Join Date: Jul 2007
Location: Amsterdam
Posts: 177
i think below sample might help you,

HTML Code:
input=$1
find <your search dir> -type f -name "$input" -print 2>/dev/null
  #6 (permalink)  
Old 01-22-2009
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,311
Afaik he wants a specific directory and look for multiple filenames and is look for a way to script it with parameters as input for the filenames.

Here another one btw:

Code:
find . -type f \( -name "file1" -o -name "file2" -o -name "file3" \) -print

For having trouble with the parameters maybe have a look here:
Internal Variables
Look for "Positional Parameters", as a start.
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 07:10 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