当前位置: 技术问答>linux和unix
帮我看段脚本啊
来源: 互联网 发布时间:2016-08-06
本文导语: 以下脚本是在sunos中写的,我看不懂什么意思,帮我翻译下啊,大概翻翻就行 #!/bin/sh # Copyright (c) 1993 by Sun Microsystems, Inc. #ident "@(#)nfsfind.sh 1.7 00/07/17 SMI" # # Check shared NFS filesystems for .nfs* files that ...
以下脚本是在sunos中写的,我看不懂什么意思,帮我翻译下啊,大概翻翻就行
#!/bin/sh
# Copyright (c) 1993 by Sun Microsystems, Inc.
#ident "@(#)nfsfind.sh 1.7 00/07/17 SMI"
#
# Check shared NFS filesystems for .nfs* files that
# are more than a week old.
#
# These files are created by NFS clients when an open file
# is removed. To preserve some semblance of Unix semantics
# the client renames the file to a unique name so that the
# file appears to have been removed from the directory, but
# is still usable by the process that has the file open.
if [ ! -s /etc/dfs/sharetab ]; then exit ; fi
# Get all NFS filesystems exported with read-write permission.
DIRS=`/usr/bin/nawk '($3 != "nfs") { next }
($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next }
($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) { print $1 }' /etc/dfs/sharetab`
for dir in $DIRS
do
find $dir -type f -name .nfs* -mtime +7 -mount -exec rm -f {} ;
done
#!/bin/sh
# Copyright (c) 1993 by Sun Microsystems, Inc.
#ident "@(#)nfsfind.sh 1.7 00/07/17 SMI"
#
# Check shared NFS filesystems for .nfs* files that
# are more than a week old.
#
# These files are created by NFS clients when an open file
# is removed. To preserve some semblance of Unix semantics
# the client renames the file to a unique name so that the
# file appears to have been removed from the directory, but
# is still usable by the process that has the file open.
if [ ! -s /etc/dfs/sharetab ]; then exit ; fi
# Get all NFS filesystems exported with read-write permission.
DIRS=`/usr/bin/nawk '($3 != "nfs") { next }
($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next }
($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) { print $1 }' /etc/dfs/sharetab`
for dir in $DIRS
do
find $dir -type f -name .nfs* -mtime +7 -mount -exec rm -f {} ;
done
|
DIRS=`/usr/bin/nawk '($3 != "nfs") { next }
($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next }
($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) { print $1 }' /etc/dfs/sharetab`
//用nawk一行一行的处理
//1:($3 != "nfs") { next } 如果该行第3域不是nfs 则直接跳到下一行 如果是nfs则执行2
//2:1成立才执行,($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next } 匹配第4域是rw 或者以rw,开头 或者以rw=开头 或者含,rw, 或者包含,rw= 或者以,rw结尾 则输出第一域(print $1) 然后直接跳到下一行
//3: 1成立,2不成立(没有匹配到),执行($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) 匹配第4域不是ro 或者不以ro,开头 或者不以ro=开头 或者不含,ro, 或者不包含,ro= 或者不以,ro结尾 则输出第一域 (print $1) 然后跳到下一行
($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next }
($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) { print $1 }' /etc/dfs/sharetab`
//用nawk一行一行的处理
//1:($3 != "nfs") { next } 如果该行第3域不是nfs 则直接跳到下一行 如果是nfs则执行2
//2:1成立才执行,($4 ~ /^rw$|^rw,|^rw=|,rw,|,rw=|,rw$/) { print $1; next } 匹配第4域是rw 或者以rw,开头 或者以rw=开头 或者含,rw, 或者包含,rw= 或者以,rw结尾 则输出第一域(print $1) 然后直接跳到下一行
//3: 1成立,2不成立(没有匹配到),执行($4 !~ /^ro$|^ro,|^ro=|,ro,|,ro=|,ro$/) 匹配第4域不是ro 或者不以ro,开头 或者不以ro=开头 或者不含,ro, 或者不包含,ro= 或者不以,ro结尾 则输出第一域 (print $1) 然后跳到下一行
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。