- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- finding filesystems with numeric UID
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 03:14 AM
тАО01-22-2003 03:14 AM
I would like to search file filesystems belonging to a user being which is only represented by its numeric UID. i.e. UID=200.
I've used the "find" utility to search for filesystems with UID=200:
#find / -user 200 -print
However, I would only like to get all directories with UID=200, which are just 1-level down the search once UID=200 is encountered.
e.g:
In the filesystem:
/home/cs/pg/users/ken_lee/MARS/tools/
if the directory MARS already have an instance of UID=200, then I would like to print it. This is regardless of the depth of filesystem tree.
Is there a way which I can specify the find utility to do so?
Or if a script is needed for such a task, could someone kindly show me how's its to be done?
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 03:46 AM
тАО01-22-2003 03:46 AM
Re: finding filesystems with numeric UID
# find . -type d -user 200 -print
Robert-Jan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 03:49 AM
тАО01-22-2003 03:49 AM
Re: finding filesystems with numeric UID
Need some clarification,in your example -
/home/cs/pg/users/ken_lee/MARS/tools is a mount point for filesystem?If so - MARS is not in this filesystem.What type of file are you
searching for (-type option of find)?If it's
a filesystem (and mounted) you can search with
find -type M (mounting point).For directories
use -type d.
Zeev.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 03:58 AM
тАО01-22-2003 03:58 AM
SolutionFollow instructions above to find directories owned by UID 200. To trim the information down, do the following,...
find etc etc >/tmp/findrslt
export LNCOUNT=`cat /tmp/findrslt|wc -l'
cat /dev/null >/tmp/outrslt
while (( $LNCOUNT > 0 ))
do
export LINE1=`head -n 1 /tmp/findrslt'
grep "^$LINE1 /tmp/findrslt |head -n 2" >>/tmp/outrslt
grep -v "^$LINE1" /tmp/findrslt >/tmp/findrslt2
mv /tmp/findrslt2 /tmp/findrslt
export LNCOUNT=`cat /tmp/findrslt|wc -l'
done
Now you have the first 2 lines of every directory tree occurence of UID 200.
Share and Enjoy! Ian
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 04:04 AM
тАО01-22-2003 04:04 AM
Re: finding filesystems with numeric UID
As shown just add the -d and get them all.
manually edit it afterwards.
There is no comfortable way with a script or find to do this.
You can play around with something like
oldir=lol
find / -user 200 -type d 2>/dev/null|
while read line
do
xx=$(echo $line|grep -v $oldir)
if [ "$xx" != "" ]
then
ll -d $line
oldir=$line
fi
done
Which will give you 1 layer down and then use these addresses to get the next one.
Regards
Steve Steel
Quote of the moment
-------------------
"We are drowning in information but starved for knowledge."
-- John Naisbitt
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 05:24 AM
тАО01-22-2003 05:24 AM
Re: finding filesystems with numeric UID
please try the attached script.
regards,
John K.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 06:43 PM
тАО01-22-2003 06:43 PM
Re: finding filesystems with numeric UID
The mount point is /home/cs and I'm searching for files and directories having UID=200. However, for the case of directories, I'm only searching for the first instance of directories with UID=200. This is because all other directories beneath that directory having UID=200 also have the UIDs as 200.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО01-22-2003 10:12 PM
тАО01-22-2003 10:12 PM
Re: finding filesystems with numeric UID
What does the expression below found in your script mean?:
oldDir = |o|
I'm getting errors like:
./uid-2.sh[3]: o: not found.
Usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwy] [-p[parasep]] -e pattern_list...
[-f pattern_file...] [file...]
Usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwy] [-p[parasep]] [-e pattern_list...]
-f pattern_file... [file...]
Usage: grep [-E|-F] [-c|-l|-q] [-insvxbhwy] [-p[parasep]] pattern_list [file...]
./uid-2.sh[6]: xx: not found.
Could you help me out?
Thanks