find function


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting find function
# 1  
Old 08-08-2012
find function

Hi,

There is requirement where I need to search if a particular directory name is present or not and if its present I need to collate the paths of the directories in a file.
I tried the below command
Code:
echo $(find /home/mqm -name "check")>>config.txt

Its saving the paths in one line(like below) but I want each directory path in one line.

/home/mqm/check /home/mqm/jay/check

Can someone please help me with this.

Thanks in advance

Last edited by Scott; 08-08-2012 at 09:46 AM.. Reason: Code tags
# 2  
Old 08-08-2012
Hi.

If you want the newlines, put double quotes around the find (echo "$(find ...)" >> config.txt).

But why do you need echo (and especially since you're writing it to a file)?

Code:
find /home/mqm -name "check">>config.txt

And if you only want directories, perhaps you should use the -d find option?
# 3  
Old 08-08-2012
hi Scott,
Your suggestion is working good.
Thanks for the fast responseSmilie

---------- Post updated at 07:59 AM ---------- Previous update was at 07:56 AM ----------

Can you also suggest the command if i want to put serial number to it...like

1|/home/mqm/check
2|/home/mqm/jay/check

I m new to shell scripting your suggestions wil be highly appreciated
# 4  
Old 08-08-2012
A quick win:
Code:
find ... | cat -n

# 5  
Old 08-08-2012
Superb...Smilie

Its working as wellSmilieSmilieSmilie

I have a general doubt regarding the website. After i logout..how can i check the replies to the thread inititated by me???
# 6  
Old 08-08-2012
If you log out, you become a "guest". i.e. you are no longer "you", therefore you would have to search for your thread. You will receive an email for the first reply since you logged out - assuming you chose that in your User Control Panel.
# 7  
Old 08-09-2012
Finding more than one directories

Hi,

can you please let me know what command i can use to collate the path information of more than one directories in a file

Thanks in advance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find function script

Hi everybody, I want your help on what, I suppose, might seem a simple task to many of you. the deal is to write a script that will look in a specific folder to see if there is any file whose size is bigger than say 1M and if so to execute a command. like if then log_rotate fi ... (3 Replies)
Discussion started by: lenci_xc
3 Replies

2. Shell Programming and Scripting

Call function from Find command

I am writing a bash script in which I am using the find command to find files, and then I'd like to send the output to a function (in the same script) that will process those results (such as test if the file is an image, and other things). However, try as I might, I can't get the function to... (6 Replies)
Discussion started by: twjolson
6 Replies

3. Shell Programming and Scripting

use File::Find function

Hello, I'm learning the perl's Find function using unix but I keep getting this error when running the script: "Not a CODE reference at /usr/lib.perl5/5.8.8/File/Find.pm line 822" - what does this mean? Does anyone know??? Here's my script: use File::Find; find (\$dir,$ENV{HOME}); ... (4 Replies)
Discussion started by: new bie
4 Replies

4. Shell Programming and Scripting

use internal function with find command

Hi, I need to use a function in the find command to do some process on the file. I'm trying: funcname(){ ... } ... find ./ -name "*" -exec funcname {} \; But somehow this is not working. I don't want to have a separate script for whatever processing the function does. I want to have... (1 Reply)
Discussion started by: victorcheung
1 Replies

5. Shell Programming and Scripting

find function name in a program file

Hello All, Is there any way to find a function name in a program file using perl. for example, there is a file called Test.C in that . . void function1(..) { <some code> } int function2(..) { . . sam() /*RA abc100*/ ... .. .. xyz()/*RA abc201*/ .. (8 Replies)
Discussion started by: Parthiban
8 Replies

6. Shell Programming and Scripting

want to find out a function name in a cpp file

I have an error in my logs as it shows some function name . 1. I dnt know where is the file.cpp located only i know the machine . 2. How to find out that the function name is loacated in which path and which file into that machine. Thanks . (1 Reply)
Discussion started by: madfox
1 Replies

7. Shell Programming and Scripting

help with find function

Hi, Im using a find function to find a specific file and print it. eg. find /path -name filename -type f -print -exec more '{}' \; The problem I have is that I need to know if the file has not been fount (ie it does not exist). I had a look at the find function and could not find anything... (4 Replies)
Discussion started by: strobo
4 Replies

8. Shell Programming and Scripting

script to find function names

hi, i am a newbie and have to write a rather complicated script. Assume that i have a variable called x and a C source code file say file1.c (these are the inputs of the script) and i need to find the names of all the functions in the C file containing x.Take the following code as an example: ... (2 Replies)
Discussion started by: samantha grace
2 Replies

9. UNIX for Dummies Questions & Answers

FIND function - system wide

Hi, I have a task to search for a file called 'Xstartup' in the whole system because there might be different versions of it which overrite eachother. Can anyone suggest a smart command to run this search ? The machine needs to scan every single folder beginning from root. Please help, I am... (5 Replies)
Discussion started by: DGoubine
5 Replies

10. UNIX for Dummies Questions & Answers

find function

I was trying the following "find" command to search for a particular file in UNIX directories: find / -name <filename> -print Result on the screen appears like: find: cannot open <..> ..permission denied Is there any way, I could avoid these type of search results and only see the... (2 Replies)
Discussion started by: pkumar_syd
2 Replies
Login or Register to Ask a Question