Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Solaris find files in directory that don't start with T or P

Posted on 2007-11-21
6
Medium Priority
?
759 Views
Last Modified: 2013-12-27
Hi
Can I use the unix find command to find files in a directory that DONT start with either a T or P
Thanks


0
Comment
Question by:daveyu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 1500 total points
ID: 20327758
Hi,

If I got your question correct, then try

find /dir -name "[!PT]*"
0
 
LVL 6

Expert Comment

by:Talmash
ID: 20327954
!P might be aliased to the last command started with P (and probably will return: PT: Event not found)

find <dir> -type f | grep -v '/P' | grep -v '/T'

you may add -maxdepth 1, BEFORE  "-type f" for search NOT in subdirectories

tal
0
 
LVL 40

Expert Comment

by:omarfarid
ID: 20328016
Hi,

Talmash:

Which shell that will go into the "[!PT*]" to subistitue a last command?

Did you try it?

Thanks
0
Survive A High-Traffic Event with Percona

Your application or website rely on your database to deliver information about products and services to your customers. You can’t afford to have your database lose performance, lose availability or become unresponsive – even for just a few minutes.

 
LVL 62

Expert Comment

by:gheist
ID: 20330196
Please explain your logic - has directory name to not begin with TP or filename? Do you need diving into subdirs?
0
 
LVL 48

Expert Comment

by:Tintin
ID: 20330624
Talmash.

I echo the comments of omarfarid.  While it's true that if your shell is bash and you use ! in some commands, eg: sed, bash will interpret this as the history recall function, but in the command omarfarid gave, this isn't the case.

Additionally, Solaris find doesn't support the -maxdepth option.  

One final point, on systems that do have GNU find, it's not important where the -maxdepth option is specified.  It certainly doesn't have to go before -type f

:-)
0
 
LVL 9

Expert Comment

by:Murugesan Nagarajan
ID: 20598264
find command usage at "ksh" shell at the following platforms:
Linux
      find $PWD -type f -regex  ".[^T|P]*"
AIX
      find $PWD -type f \( -name "[!T|P]*" \)
HP-UX
      find $PWD -type f \( -name "[!T|P]*" \)
SunOS
      find $PWD -type f \( -name "[!T|P]*" \)
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Suggested Courses

704 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question