The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 pattern in a string and rename deepakgang UNIX for Dummies Questions & Answers 6 06-02-2008 01:43 AM
SED Search Pattern and Replace with the Pattern racbern Shell Programming and Scripting 4 03-15-2008 05:59 AM
Search for a pattern from the result of search boopathi_d Shell Programming and Scripting 3 12-05-2007 09:54 AM
Search Mulitiple String pattern in a file krishnan_6015@y Shell Programming and Scripting 2 11-23-2007 04:03 AM
Search file for pattern and grab some lines before pattern frustrated1 Shell Programming and Scripting 2 12-22-2005 03:41 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 10-29-2007
sainj sainj is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
Advance string pattern search Please

Here is my problem..
1. I want to search all those files with file name starting AJ128****
(in all the sub directories also)
2. I want to search for the follwoing type of string
line beging with string - 'AK*any_1_char*any_2_char*510'
3. I need to display list of file names
4. I need to display total number of files that have the above string

Thanks for the help in advance. I am using sun solaris.
  #2 (permalink)  
Old 10-30-2007
Yogesh Sawant's Avatar
Yogesh Sawant Yogesh Sawant is offline Forum Staff  
Part Time Moderator and Full Time Dad
  
 

Join Date: Sep 2006
Location: Rossem, Tazenda
Posts: 1,086
Quote:
Originally Posted by sainj View Post
Here is my problem..
1. I want to search all those files with file name starting AJ128****
(in all the sub directories also)
Code:
find . -type f -name "AJ128*"
check the options of find commands to know more details

Quote:
Originally Posted by sainj View Post
2. I want to search for the follwoing type of string
line beging with string - 'AK*any_1_char*any_2_char*510'
Code:
grep 'AK*any_1_char*any_2_char*510' *
This will search the given string in all files present in current directory

Quote:
Originally Posted by sainj View Post
3. I need to display list of file names
Code:
grep -H 'AK*any_1_char*any_2_char*510' *
-h option shows filename on every line. To show only filenames where match is found, use:
Code:
grep -H ha * | cut -d ":" -f1 | uniq
Quote:
Originally Posted by sainj View Post
4. I need to display total number of files that have the above string

Thanks for the help in advance. I am using sun solaris.
Code:
grep -H ha * | cut -d ":" -f1 | uniq | wc -l
  #3 (permalink)  
Old 10-30-2007
sainj sainj is offline
Registered User
  
 

Join Date: Oct 2007
Posts: 2
Yogesh.. Thanks for the reply..

any_1_char mean = > it can be Y or N or 1 etc
any_2_char means => it can be 18, 21, 01.. etc

So for the follwing 'AK*any_1_char*any_2_char*510', I am using regular expression. Like below.

find . -name AJ128\* -exec /usr/xpg4/bin/grep -il -E 'AK\*N\**\*510' {} \; | wc -l

But it was not working.

1. And I want to retrieve all file names with all the conditions
2. And I want to retrieve total no of files with all the conditions

Thanks for the help..
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 03:23 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