find the file names having specified pattern at specified position in the current directory


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers find the file names having specified pattern at specified position in the current directory
# 1  
Old 08-30-2011
Question find the file names having specified pattern at specified position in the current directory

I would need a command for finding first 15000 of the file names whose 25th postion is 5 in the current directory alone.


I do have this painful command

find . -name '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]5*' | head -15000 | cut -c3-

please refine this.

Of course the above command also searches in the sub directories which I dont want.

please dont use 'maxdepth' since it would not work on my unix.Smilie

appreciate your help!
# 2  
Old 08-30-2011
Code:
find . | egrep '^.{24}5' | head ...

You can just use "ls" to search only in the current directory.
# 3  
Old 08-30-2011
one more ..
Code:
$ ls -ltr | grep -v ^d | awk '{print $9}' | sed '/^.\{24\}5/!d'

# 4  
Old 08-30-2011
Thank u for your help

My files naming convention would be as below. When I use the following command its listing out both naming conventon files. I just need the list of files of first type alone.
ls | egrep '^.{21}8' | head -15000

3914850220110830173809000437activityLog.txt
laatws74_9_aLog_20110830225437_1.txt

can you plz help me on this
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find a file with a specific pattern for current sysdate & upon find email the details?

I need assistance with following requirement, I am new to Unix. I want to do the following task but stuck with file creation date(sysdate) Following is the requirement I need to create a script that will read the abc/xyz/klm folder and look for *.err files for that day’s date and then send an... (4 Replies)
Discussion started by: PreetArul
4 Replies

2. Shell Programming and Scripting

Find the position of a pattern on a line from a csv file

hello I'm doing a unix program and i'm using many file csv.in each csv file the colums are separated by ";" I would like to know the position of a pattern. For example for a line yyyy, bbbb, cccc; ddddd;eeee. I will like for example by finding the position of the pattern "cccc" and the response is... (6 Replies)
Discussion started by: papis
6 Replies

3. Programming

help with printing file names in current directory for C

How do I print all the file names in current directory in C? (6 Replies)
Discussion started by: omega666
6 Replies

4. Shell Programming and Scripting

How to find pattern in file names?

I have some files, those are abbreviated (ed,ea, and bi) company_ed_20100719.txt company_ea_20100719.txt company_bi_20100719.txt I would like to rename these files by replacing ed with EmployeeDetails ea with EmployeeAddress bi with BankInfomration as company_... (3 Replies)
Discussion started by: LinuxLearner
3 Replies

5. Shell Programming and Scripting

Find Directory from array of file names with paths

I have a script that generates a variable with the location of a file and its complete path. What i want to do is to "cd" to the directory where that file is located using the path name of the file. GIS has absolutely failed me. For example when i run my script it generates a variable called... (1 Reply)
Discussion started by: Knome
1 Replies

6. UNIX for Dummies Questions & Answers

How to find the list of 5 largest file in current directory?

Hello, How to find the list of 5 largest(size wise) file in current directory?i tried using ls -l | sort -t " " -r +5 -6 -n | head -5 but this is not giving correct output as ls -l command gives 1 extra line of output that is how many total files are there!so by running the above... (4 Replies)
Discussion started by: salman4u
4 Replies

7. AIX

find for specific content in file in the directory and list only file names

Hi, I am trying to find the content of file using grep and find command and list only the file names but i am getting entire file list of files in the directory find . -exec grep "test" {} \; -ls Can anyone of you correct this (2 Replies)
Discussion started by: madhu_Jagarapu
2 Replies

8. UNIX for Dummies Questions & Answers

copying a pattern of files in one directory into other with new pattern names...

Hi, I have to copy a set of files abc* in /path/ to /path1/ as abc*_bkp. The list of files appear as follows in /path/: abc1 xyszd abc2 re2345 abcx .. . abcxyz I have to copy them (abc* files only) into /path1/ as: abc1_bkp abc2_bkp abcx_bkp .. . (6 Replies)
Discussion started by: new_learner
6 Replies

9. Shell Programming and Scripting

find the length of file names in a directory?

Hi, how can find length of file names in a directory. Examp: I have a directory with name "d1". directory: d1 files: aaa.log bbb.log abcd.log abcdef.log I wold like out put like: file name legnth aaa.log 3 bbb.log 3 abcd.log 4 abcdef.log 5 (5 Replies)
Discussion started by: koti_rama
5 Replies
Login or Register to Ask a Question