Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2007-11-21
6
Medium Priority
?
761 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 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

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

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

885 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