- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- find a file down 1 level only
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
тАО07-04-2002 01:51 AM
тАО07-04-2002 01:51 AM
/home/user1/projA/scheda
and a file namely "term" was found in both /home/user1/projA and /home/user1/projA/scheda
let say i want to seach a the file "term" in /home/user1/projA only but not any level down below, i use:
# find /home/user1 -name term
the output also show me the file under /home/user1/projA/scheda. what option should i use in find command to limit my search at certain level only? Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 01:59 AM
тАО07-04-2002 01:59 AM
Re: find a file down 1 level only
If it is just 1 level down as indicated in your query, then,
1) At the command line:
# ls /home/user1|grep term;for i in /home/user1/*;do if [ -d $i ];then ls $i|grep term;fi;done
2) As a script:
==========================
#!/sbin/sh
DIR=/home/user1
SEARCH=term
ls $DIR | grep $SEARCH
for i in $DIR/*
do
if [ -d $i ]
then
ls $i | grep $SEARCH
fi
done
==========================
Hope this helps. Regards.
Steven Sim Kok Leong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 01:59 AM
тАО07-04-2002 01:59 AM
Re: find a file down 1 level only
You can use either;
cd /home/user1
ls */*term* (the first * means only go down 1 level, if you wanted 2 levels then do ls */*/*term*)
or
ls projA/*term*
or
ls /home/uers/projA/*term*
This will search only that directory.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 01:59 AM
тАО07-04-2002 01:59 AM
Solution- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 02:04 AM
тАО07-04-2002 02:04 AM
Re: find a file down 1 level only
make a script myfind like this
#myfind
#
#params dir and filename
dir=$1
file=$2
echo $dir"/"$(ls -1 $dir|grep $file$)
Steve Steel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 02:05 AM
тАО07-04-2002 02:05 AM
Re: find a file down 1 level only
Hi
find -fsonly /home/user1/projA -name filename
John.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-04-2002 02:10 AM
тАО07-04-2002 02:10 AM
Re: find a file down 1 level only
John.