Question: How to generate a list of files and directories of the root filesystem, more precisely files and directories that entirely reside on the hd4 logical volume. Other criteria:
  • symbolic links need not be listed;
  • active mount points must not be listed (e.g. /tmp, /opt, /var, etc.);
  • only first level directories needed (e.g. /app, but not /app/program);
  • dotted files and directories must be included in the list (e.g. /.ssh, /.profile).

Solution:

  To find file names only:
find / ! -name / -prune ! -type l |grep -vwE $(mount|tail +3|awk '{if ( /^[a-zA-Z]/ )  {print $3} else {print $2}}'|grep -vE "^/.*/|^/$"|xargs|tr ' ' '|')
    To show all the detail:
find / ! -name / -prune ! -type l -ls|grep -vwE $(mount|tail +3|awk '{if ( /^[a-zA-Z]/ )  {print $3} else {print $2}}'|grep -vE "^/.*/|^/$"|xargs|tr ' ' '|')
  It is also useful when you try to check what is filling up root(/) filesystem:
du -sk $(find / ! -name / -prune ! -type l |grep -vwE $(mount|tail +3|awk '{if ( /^[a-zA-Z]/ )  {print  $3} else {print $2}}'|grep -vE "^/.*/|^/$"|xargs|tr ' ' '|'))|sort -k1rn