mount -v 2>/some/file
명령을 실행 한 후 다음 정규식을 사용하여 다른 스크립트로 구문 분석하는 스크립트가 있습니다 .
^.*[\ \t]+type[\ \t]+nfs(?![\ \t]+.*\b(?:nosuid|nosetuid)\b).*
내가 겪고 있는 문제는 마운트를 방지하는 예외가 있는 일부 NFS 마운트가 있다는 것입니다 nosuid
(Solaris 11 IPS 저장소입니다). 이제 알려진 설치를 제외하도록 정규식을 수정해야 합니다...
참고로 다음은 몇 가지 샘플 출력입니다 mount -v
.
$ mount -v
/dev/dsk/c1t0d0s0 on / type ufs read/write/setuid/devices/rstchown/intr/largefiles/logging/xattr/onerror=panic/dev=840000 on Fri Sep 6 12:10:35 2013
/devices on /devices type devfs read/write/setuid/devices/rstchown/dev=4c00000 on Fri Sep 6 12:10:25 2013
ctfs on /system/contract type ctfs read/write/setuid/devices/rstchown/dev=4c80001 on Fri Sep 6 12:10:25 2013
proc on /proc type proc read/write/setuid/devices/rstchown/dev=4c40000 on Fri Sep 6 12:10:25 2013
mnttab on /etc/mnttab type mntfs read/write/setuid/devices/rstchown/dev=4cc0001 on Fri Sep 6 12:10:25 2013
swap on /etc/svc/volatile type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00001 on Fri Sep 6 12:10:25 2013
objfs on /system/object type objfs read/write/setuid/devices/rstchown/dev=4d40001 on Fri Sep 6 12:10:25 2013
sharefs on /etc/dfs/sharetab type sharefs read/write/setuid/devices/rstchown/dev=4d80001 on Fri Sep 6 12:10:25 2013
/usr/lib/libc/libc_hwcap1.so.1 on /lib/libc.so.1 type lofs read/write/setuid/devices/rstchown/dev=840000 on Fri Sep 6 12:10:31 2013
fd on /dev/fd type fd read/write/setuid/devices/rstchown/dev=4f00001 on Fri Sep 6 12:10:35 2013
swap on /tmp type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00002 on Fri Sep 6 12:10:38 2013
swap on /var/run type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00003 on Fri Sep 6 12:10:38 2013
/dev/dsk/c1t0d0s7 on /export/home type ufs read/write/setuid/devices/rstchown/intr/largefiles/logging/xattr/onerror=panic/dev=840007 on Fri Sep 6 12:10:44 2013
sample-ips:/ips/blargSolaris11.1 on /blargSolaris11.1 type nfs remote/read/write/setuid/devices/rstchown/soft/xattr/dev=8c00001 on Tue Sep 10 12:07:46 2013
다음과 같이 일치하는 줄의 시작 부분에 있는 설치를 기반으로 IP별 설치를 제외하도록 정규식을 수정해 보았습니다.
^(.*|[^sample])[\ \t]+type[\ \t]+nfs(?![\ \t]+.*\b(?:nosuid|nosetuid)\b).*
그러나 이것은 작동하지 않습니다 ...
답변1
이 정규식으로 무엇을 하고 있는지 잘 모르겠지만 나에게는 괜찮은 것 같습니다. Perl인 것 같아서 GNU 버전의 grep -P
스위치를 사용하여 다음과 같이 정규식을 사용했습니다.
$ column -t mount.txt | \
grep -vP '^(.*|[^sample])[\ \t]+type[\ \t]+nfs(?![\ \t]+.*\b(?:nosuid|nosetuid)\b).*'
예
$ column -t mount.txt | \
grep -vP '^(.*|[^sample])[\ \t]+type[\ \t]+nfs(?![\ \t]+.*\b(?:nosuid|nosetuid)\b).*'
/dev/dsk/c1t0d0s0 on / type ufs read/write/setuid/devices/rstchown/intr/largefiles/logging/xattr/onerror=panic/dev=840000 on Fri Sep 6 12:10:35 2013
/devices on /devices type devfs read/write/setuid/devices/rstchown/dev=4c00000 on Fri Sep 6 12:10:25 2013
ctfs on /system/contract type ctfs read/write/setuid/devices/rstchown/dev=4c80001 on Fri Sep 6 12:10:25 2013
proc on /proc type proc read/write/setuid/devices/rstchown/dev=4c40000 on Fri Sep 6 12:10:25 2013
mnttab on /etc/mnttab type mntfs read/write/setuid/devices/rstchown/dev=4cc0001 on Fri Sep 6 12:10:25 2013
swap on /etc/svc/volatile type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00001 on Fri Sep 6 12:10:25 2013
objfs on /system/object type objfs read/write/setuid/devices/rstchown/dev=4d40001 on Fri Sep 6 12:10:25 2013
sharefs on /etc/dfs/sharetab type sharefs read/write/setuid/devices/rstchown/dev=4d80001 on Fri Sep 6 12:10:25 2013
/usr/lib/libc/libc_hwcap1.so.1 on /lib/libc.so.1 type lofs read/write/setuid/devices/rstchown/dev=840000 on Fri Sep 6 12:10:31 2013
fd on /dev/fd type fd read/write/setuid/devices/rstchown/dev=4f00001 on Fri Sep 6 12:10:35 2013
swap on /tmp type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00002 on Fri Sep 6 12:10:38 2013
swap on /var/run type tmpfs read/write/setuid/devices/rstchown/xattr/dev=4d00003 on Fri Sep 6 12:10:38 2013
/dev/dsk/c1t0d0s7 on /export/home type ufs read/write/setuid/devices/rstchown/intr/largefiles/logging/xattr/onerror=panic/dev=840007 on Fri Sep 6 12:10:44 2013
sample-ips:/ips/blargSolaris11.1
예상대로 로 시작하는 줄이 필터링되는 것을 볼 수 있습니다 .