LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris
User Name
Password
Solaris / OpenSolaris This forum is for the discussion of Solaris, OpenSolaris, OpenIndiana, and illumos.
General Sun, SunOS and Sparc related questions also go here. Any Solaris fork or distribution is welcome.

Notices


Reply
  Search this Thread
Old 07-01-2019, 02:18 AM   #1
ultrakiasu
LQ Newbie
 
Registered: May 2018
Posts: 5

Rep: Reputation: Disabled
Find all files in entire server except /proc and /system


I am struggling to write a script to list out all the files in the solaris server and generate the the checksum of all the files.

find / -type f -exec digest -v -a md5 {} \; > /all_files_md5sum.txt

Since /proc and /system having some unreadable files, my script will hang indefinitely.

how could I achieve it on solaris11 with GNU find syntax with -path and -prune.
and also on legacy solaris10 with older non-GNU find?

Currently I am calling a script to filter out the /proc and /system via grep thru an external script
using

find / -type f -exec external_script {} \;

which contains:
dir=$1
echo $dir | grep ^/proc
if [ $? -eq 0 ]; then
exit
fi
echo $dir | grep ^/system
if [ $? -eq 0 ]; then
exit
fi
digest -v -a md5 $1 >> /all_files_md5sum.txt

Last edited by ultrakiasu; 07-08-2019 at 04:05 AM.
 
Old 07-01-2019, 03:13 AM   #2
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
Wouldn't it be the same for each system?

Code:
find ./ -path '/proc' -prune -o -path '/system' -prune \
    -o -type f -exec digest -a md5 {} \; > /all_files_md5sum.txt
You may have to exclude more than just those. What are you really looking for?
 
Old 07-01-2019, 03:37 AM   #3
ultrakiasu
LQ Newbie
 
Registered: May 2018
Posts: 5

Original Poster
Rep: Reputation: Disabled
Nope...

Your syntax still listing /proc

Native Solaris 10 and Solaris 11, does not come with GNU find, thus there is no -path syntax in find.
The Supplement CD for Solaris 11 does include gnu find package, but solaris 10 it is too old and not included.
 
Old 07-01-2019, 03:45 AM   #4
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,308
Blog Entries: 3

Rep: Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721Reputation: 3721
That was from the OpenBSD version, which also has -path. I guess it's been too long since I've looked at any Solaris.
 
Old 07-01-2019, 09:37 AM   #5
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by ultrakiasu View Post
find / -type f -exec digest -v -a md5 {} \; > /all_files_md5sum.txt

Since /proc and /system having some unreadable files, my script will hang indefinitely.
I do not know if Solaris knows the -mount or -xdev option, but find with either option will NOT descend into mounted filesystems below the starting directory.
If there are any fs'es mounted which you DO want to search (i.e. /home) you will have to add them to the commandline, though:
Code:
find / /home -xdev -type f (etc.)
 
Old 07-08-2019, 03:37 AM   #6
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,792

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
The -path and -prune stuff in post #2 works fine - if -path would be supported.
Note that for testing you must -print in the last -o branch; the implicit print does \( ... \) -print i.e. prints in all branches.

For the Solaris find I suggest to grep first.
Code:
#!/bin/sh
dirs=`
cd /
ls | fgrep -vx "\
proc
system"
`
(
cd /
# word-split on \n only
IFS=
# do not glob-match
set -f
find $dirs -type f -exec digest -a md5 {} \; > /all_files_md5sum.txt
)
The ( ) enforce a sub shell, so the IFS= and set -f and cd / do not impact a following main shell code.
(Also the ` ` is a sub shell, so its cd / won't impact the main shell.)

Last edited by MadeInGermany; 07-08-2019 at 05:20 AM. Reason: Need another cd /
 
Old 07-08-2019, 04:24 AM   #7
MadeInGermany
Senior Member
 
Registered: Dec 2011
Location: Simplicity
Posts: 2,792

Rep: Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201Reputation: 1201
In bash you can use extglob rather than fgrep:
Code:
#!/bin/bash
(
shopt -s extglob
find /!(proc|system) -type f -exec digest -a md5 {} \; > /all_files_md5sum.txt
)
Again the ( ) limit the scope of the shopt -s extglob
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Are linux proc filesystem files like /proc/stat unlinked and recreated upon update? Longman Linux - Server 9 01-14-2019 01:47 PM
How to copy an entire directory structure except certain files? thanhvn Programming 9 01-27-2012 11:41 AM
Delete all .log files and .bat files except the most recent? alancampbell6 Linux - Newbie 3 12-15-2011 09:17 AM
[SOLVED] How to find duplicate files and delete all except most recent version anon091 Linux - Newbie 4 08-17-2010 10:13 AM
Boot hang after 'proc on /proc type proc (rw)' Hagoromo Slackware 13 10-05-2007 05:03 PM

LinuxQuestions.org > Forums > Other *NIX Forums > Solaris / OpenSolaris

All times are GMT -5. The time now is 03:33 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration