Sunday, August 2, 2009

Search Linux?

HI,


Can someone post the exact command to search particular file in whole linux file system same as i used to do in dos


c:\dir *myname*.* /p/s


This will search every file in all c drive containing myname whethere it is any directory. The command equivalent to this command.

Search Linux?
ls %26lt;your filename%26gt;





ls -als %26lt;yourfilename%26gt; to display more details regarding the file
Reply:Command is: find / -name '*myname*'


Let's disect this:


find - the actual command


/ - which directory to search, in this case the entire filesystem


-name - search by name


'*myname*' - file pattern to search for.





Find is a very versatile tool, for example, if you wish to list only directories matching your pattern, you would use:


find / -name '*myname*' -type d


or a file


find / -name '*myname*' -type f


If you want to limit the depth of directory search


find / -name '*myname*' -maxdepth 2


or if you wish to perform an action on every match found:


find / -name '*myname*' -exec ls -l {} ';'
Reply:find / -name '*myname*'
Reply:to search a file


locate filenametosearch


or


find /dir/where/to/search -name filenametosearch





to list a directory


ls --color |more

radiata

No comments:

Post a Comment