Recursively check the file/dir names


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Recursively check the file/dir names
# 1  
Old 05-27-2008
Recursively check the file/dir names

Hi,

' recgrep find . | xargs grep ' is used to scan the contents recursively. I have a different requirement. I need to scan just the names and check for a pattern and display with fullpath. Is that already available? Closest that I am trying is 'ls -R | grep pattern' Here I would get multiple lines , but I don't get the path.

I am trying to scan for filenames under a big dir
# 2  
Old 05-27-2008
This should be in the basic or for dummies forum.
Did you check the manpage for find?
Code:
find $dir -name $pattern -exec grep -l $string {} \;

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Renaming File Names in a folder/Dir

Hi Team, I'm new to Unix shell scripting . I've the following requirement A folder contains the list of files with the following format ab.name.11.first ab.name.12.second ab.name.13.third ---------- I have to rename the above file to like below ... (6 Replies)
Discussion started by: smile689
6 Replies

2. Shell Programming and Scripting

Perl code to check date and check files in particular dir

Hi Experts, I am checking how to get day in Perl. If it is “Monday” I need to process…below is the pseudo code. Can you please prove the code for below condition. if (today=="Monday" ) { while (current_time LESS THAN 9:01 AM) ... (1 Reply)
Discussion started by: ajaypatil_am
1 Replies

3. Shell Programming and Scripting

Check for particular files and compare the file names

Hi, Below are the 2 files in directory /tmp: masterCSF242323.img indexCSF242323.img 1) I want to compare if both the number (242323) are same in both the files. If they are same print - Files matching, else print files do not match. 2) Also if only index file is present in that... (7 Replies)
Discussion started by: apatil65
7 Replies

4. Shell Programming and Scripting

Get dir names.

Hi, i have a directory and sub directory`s inside. i want to take all the files name and add them into array. for example : $ ls Debug script.c src typescript $ Array = Debug Array= scripts.c Array = src Array = typescript. Thanks for the help. Or. (2 Replies)
Discussion started by: orushw
2 Replies

5. UNIX for Dummies Questions & Answers

How to list all files in dir and sub-dir's recursively along with file size?

I am very new to unix as well as shell scripting. I have to write a script for the following requirement. In have to list all the files in directory and its sub directories along with file path and size of the file Please help me in this regard and many thanks in advance. (3 Replies)
Discussion started by: nmakkena
3 Replies

6. Shell Programming and Scripting

Find the number of non-duplicate names recursively.

Hi, here comes another newbie question: How to find the number of non-duplicate names recursively? For example, my files are stored in the folders like: If I do find . -depth -name "*.txt" | wc -l This will gives out a result "4". One .txt file named "1.txt" in folder "1", and... (2 Replies)
Discussion started by: jiapei100
2 Replies

7. Shell Programming and Scripting

Copy Files to Dir and Check If File Exists

Hi everyone. I am trying to write a bash script that will copy files from one directory to another but I need to be able to check the directory that I'm copying the files to and see if the file already exists. If it does I need to add a number at the end of the copied file. Thanks for your help. (3 Replies)
Discussion started by: snag49ers
3 Replies

8. UNIX for Dummies Questions & Answers

Copying dir (and sub dir) file names from ftp server to txt file in diff server

Hey all, i want to copy only the file names from an ftp server (directory and all sub directory) to a text file in another server (non ftp), i.e. i want to recursively move through directories and copy only the names to a text file. any help is appreciated...thank you in advance (1 Reply)
Discussion started by: deking
1 Replies

9. Shell Programming and Scripting

How to check the file size in a dir

Hi all, I need to check the size of all files in a DIR.Can any one help me out from this? This is my code: filenames=`ls -l | cut -c 55-90` for f in $filenames do if then echo $f done Output: file access denied. *files have read permission alone. (6 Replies)
Discussion started by: bsathishmca
6 Replies

10. Shell Programming and Scripting

to check redundant file names

hi i have a very simple problem iam moving files from download to archive folder but before such a transfer want to make sure no two file of same are present in my download directory how to check for redundant file names i thought of using WC but it counts inside the file (lines and... (5 Replies)
Discussion started by: maverick
5 Replies
Login or Register to Ask a Question