aspose file tools*
The moose likes Linux / UNIX and the fly likes search in unix for files without extension Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "search in unix for files without extension" Watch "search in unix for files without extension" New topic
Author

search in unix for files without extension

Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Hi,
I need to find the files without any extensions under one directory. What is the Unix command for same.
Also how can i narrow down my search so that I can exclude some files from search
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

It's actually two commands. You first need "ls" to list the files in that directory. You then need to pipe it to grep to get the lines that don't match.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

Take a look at the find command, and on that man page, the ! (or -not) operator, the -depth option, and -name option, and the -type option. A combination of these will work.

In thinking about this, my answer is probably better for answering homework assignment. Jeanne's is way easier if you are actually trying to get the work done with the least amount of effort.


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30294
    
150

I'd use Andrew's way if I needed to go more than one directory in. If all the files are in the top level directory I am in, ls is simpler.
Anand Bhatt
Ranch Hand

Joined: May 30, 2007
Posts: 189
Both if you a Big thanks for quick reply .I will definetly use both optiosn sugested by you.
I would like it more clear ,and let see if you cansugest some more accurate command
I have root directory emp and inside emp there are lots of sub-directories(depth could be from 1.........10+ level)
Now my exact reuirement is:
I need to list/find all shell scripts files( unfortunately those files have no extension like .sh,thse files contains .sh a ) under this top level directory i,e. emp .

In summary : List down those files having no extension and those files contains .sh in it.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11423
    
  85

I still think my way solves this perfectly - just leave out the -depth option since you do not care about how many directories you traverse.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: search in unix for files without extension