- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: howto exclude in a loop
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
тАО11-21-2007 01:39 AM
тАО11-21-2007 01:39 AM
I want to umount a set of filesystems on various systems except VG00 filesystems and an NFS mount.
I have attempted a for and while loop for this with no success.
I created a file with the mountpoints I want remaining mounted then put this into a while loop:
while read MOUNT
do
for FS in `df|awk 'NR>1 {print $6}'`
do
if [ $FS = $MOUNT ] ; then
etc
etc
this doesnt work and am struggling to come up with something suitable.
any ideas?
thanks in advance.
chris.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2007 01:47 AM
тАО11-21-2007 01:47 AM
SolutionThen pipe the output to grep:
for FS in $(df|awk 'NR>1 {print $6}') | fgrep -xvf mount-exclude-file); do
You would have to be careful if the files in mount-exclude-file are proper substrings of any other mount point. I think -x will cause "/" to not match any other mount point.
- Tags:
- grep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2007 01:49 AM
тАО11-21-2007 01:49 AM
Re: howto exclude in a loop
Why dont you try with another reasoning:
create your MOUNT file by doing a
bdf|grep -v vg00 (and whatever needs to stay mounted...) to extract your filesystems to unmount?
All the best
Victor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2007 01:50 AM
тАО11-21-2007 01:50 AM
Re: howto exclude in a loop
To conditionally skip a step in your loop and begin again at it's top you can use 'continue'.
For example:
#!/usr/bin/sh
df | while read FS X
do
if [ "${FS}" = /tmp ];then
continue
else
echo ${FS}
fi
done
If you want to exit the loop at any time, use 'break'.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО11-21-2007 02:22 AM
тАО11-21-2007 02:22 AM
Re: howto exclude in a loop
Thanks for the advice.
Chris