Solved

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

Posted on 2007-11-21
6
752 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
6 Comments
 
LVL 40

Accepted Solution

by:
omarfarid earned 500 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 61

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 7

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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 get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now