Filename pattern count


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Filename pattern count
# 1  
Old 01-18-2011
Filename pattern count

Hi

I have the following files in a directory -

Code:
ds_pl_W_Test
ds_pl_list_Test
ds_pl_list_Test
ds_pl_listl_Test
ds_pl_file_Test
ds_pl_xx_Test

I would like to count the number files in the directory that contain the word "list"

I tried the following but it returns zero -

Code:
find . -name "*_list_" | wc -l

Please could you assist.

Last edited by radoulov; 01-18-2011 at 05:32 AM.. Reason: Code tags, please!
# 2  
Old 01-18-2011
You're pattern seems wrong:

Code:
find . -name '*_list_*' | wc -l

# 3  
Old 01-18-2011
Hi radoulov

Thanks.When I ran the command it worked.I wanted to know when creating a script how do you point this command to the correct directory.

e.g - all the files are stored in a directory named C:\Dump

Normally when accessing a file you would say something like -

awk -F'[/"]' '{print $5,$6,$7}' filetest.dsx

Were filetest.dsx is file that you are printing from.

So basically I need to create a script using the command you have given me but point it to the correct directory within the script.

I hope I did not confuse you

Thanks for your help
# 4  
Old 01-18-2011
The directory to be searched goes right after the find command,
a litteral dot '.' means the current directory.
So you could write something like:

Code:
find C:\dump -name ...

I don't know which Unix emulation you're using.
If it's Cygwin, you could access the above directory like this:

Code:
find /cygdrive/c/dump -name ...

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Match filename pattern with -f

Hello All, I have two issues. 1).I want to check if directory exists and inside that if file exists with today's date minus one. I can check directory exists but how can i check only a pattern of filename in that directory.Name of file is files-20170105-09.gz. 2).Also i want to exit immediately... (6 Replies)
Discussion started by: looney
6 Replies

2. Shell Programming and Scripting

Identify file pattern, take count of pattern, then act

Guys - Need your ideas on a section of code to finish something up. To make a long story short, I'm parsing a print output file that goes to pre-printed forms. I'm intercepting it, parsing it, formatting it, cutting it up into individual pages, grabbing the text I want in zones, building an... (3 Replies)
Discussion started by: ampsys
3 Replies

3. Shell Programming and Scripting

To count underscore in filename

Hi All I have a filename like below adsf_ghjt_kop_pol.csv Can you please get me a command for counting the number of underscore in the filename. In the above filename I should get output as 3, since the file name is having three underscore (5 Replies)
Discussion started by: ginrkf
5 Replies

4. Shell Programming and Scripting

File Count and FileName

Hi I have a set of files in one directory like below FIN_TASK1.csv FINA_TASK2.csv FIN_TASK3.csv. I want a command to print the count in each file and the correspong file name into one file.My expected output is given below cat filcount.txt 2 "FIN_TASK1.csv" 4 "FIN_TASK2.csv" ... (3 Replies)
Discussion started by: ginrkf
3 Replies

5. Shell Programming and Scripting

Search for a pattern in a String file and count the occurance of each pattern

I am trying to search a file for a patterns ERR- in a file and return a count for each of the error reported Input file is a free flowing file without any format example of output ERR-00001=5 .... ERR-01010=10 ..... ERR-99999=10 (4 Replies)
Discussion started by: swayam123
4 Replies

6. Shell Programming and Scripting

Count the number of occurrences of a pattern between each occurrence of a different pattern

I need to count the number of occurrences of a pattern, say 'key', between each occurrence of a different pattern, say 'lu'. Here's a portion of the text I'm trying to parse: lu S1234L_149_m1_vg.6, part-att 1, vdp-att 1 p-reserver IID 0xdb registrations: key 4156 4353 0000 0000 ... (3 Replies)
Discussion started by: slipstream
3 Replies

7. Shell Programming and Scripting

Does Filename Match Pattern

Hi, I am writing a BASH script. I have a list of files and I would like to make sure that each is of a specific pattern (ie *.L2). If not I would like to remove that file. How do I test whether a filename matches a given pattern? Thanks a lot. Mike (10 Replies)
Discussion started by: msb65
10 Replies

8. Shell Programming and Scripting

Filename and Pattern matching

Hiiiii every one, I am facing a problem while giving a file name which has space in it. The problem is ... I have to read a file where the set of input files are stored. Now getting that name I have to open the file and i have to extract the name of the user from where it is written like"by... (2 Replies)
Discussion started by: kheyali Mitra
2 Replies

9. Shell Programming and Scripting

nawk-how count the number of occurances of a pattern, when don't know the pattern

I've written a script to count the total size of SAN storage LUNs, and also display the LUN sizes. From server to server, the LUNs sizes differ. What I want to do is count the occurances as they occur and change. These are the LUN sizes: 49.95 49.95 49.95 49.95 49.95 49.95 49.95 49.95... (2 Replies)
Discussion started by: cyber111
2 Replies

10. UNIX for Dummies Questions & Answers

Count caraters on filename

Hello people. I need some help to do this: I've got some files that i need to count the caracters of filenames. 20080209_2000591574_237004076372.xml 20080202_1360584_267002636042.xml The minimum is 15 . If some file with less must move them to another directory. Obviously these... (3 Replies)
Discussion started by: osramos
3 Replies
Login or Register to Ask a Question