Solved

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

Posted on 2007-11-21
6
755 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
remove a combination of patterns from a file 15 70
withoutTen challenge 14 132
Bash Script to Analyze Oracle Schemas 11 117
lunix and unix command 21 86
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 …
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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 will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

838 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