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

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

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)?

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

And if you only want directories, perhaps you should use the -d find option?

hi Scott,
Your suggestion is working good.
Thanks for the fast response:)

---------- 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

A quick win:

find ... | cat -n

Superb...:slight_smile:

Its working as well:):):slight_smile:

I have a general doubt regarding the website. After i logout..how can i check the replies to the thread inititated by me???

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.

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

Not sure what you're asking, could you give an example?