find only current directory (universal)

find . \( ! -name . -prune \) \( -type f -o -type l \)
you must be in the directory to analyse report all files and links in the currect directory, not recursively. this find command ahs been tested on hp-ux/linux/aix/solaris.
Sample Output
find . \( ! -name . -prune \) \( -type f -o -type l \)
./bosinst.data
./smit.log
./lib

1
By: mobidyc
2009-09-12 15:58:56

1 Alternatives + Submit Alt

What Others Think

how does this differ from just using: find . -maxdepth 1 ??
bwoodacre · 454 weeks ago
hmm I dont have access to the other Unixes anymore and I'm not sure if they support this, but on Linux you can do this with find . -maxdepth 1 ! -type d
sitaram · 453 weeks and 6 days ago
the -maxdepth flag works only on Gnu release. HP-UX, IBM AIX and Sun Solaris have their own 'find' command by default. * these find parameters works everywhere.
mobidyc · 453 weeks and 5 days ago
Only works for the current directory? This does not work: find /path/to/dir \( ! -name /path/to/dir -prune \) \( -type f -o -type l \) How does one do this on AIX with the absolute path instead of pwd (.)?
knh · 195 weeks and 1 day ago
For example, to find files and links older than four weeks using find on AIX: find /path/to/dir/. ! -name . -prune \( -type f -o -type l \) -mtime +28
knh · 195 weeks and 1 day ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: