Score:0

Using find's -prune action

cn flag

In this script:

#!/bin/bash

# Get the current epoch time minus 1 second to be sure all files are captured. 
eptime=$((EPOCHSECONDS-1))

# Execute the commands that will do the sought for file changes:
gio set "/home/stephen/Desktop/Flameshot.desktop" "metadata::trusted" no
gio set "/home/stephen/Desktop/Flameshot.desktop" "metadata::trusted" yes

# Create a test file to verify the script works
touch ./gio_set_file_changes_test.txt

# List all files changed after eptime
eptimestart=$EPOCHSECONDS
find / -name /proc/ -prune -o -newermt @$eptime -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r
echo Search time $((EPOCHSECONDS-eptimestart)) seconds
rm ./gio_set_file_changes_test.txt

The find command's -prune action fails to eliminate the /proc directory as intended. What is the correct syntax to do this?

Score:0
hr flag

If you hadn't redirected the standard error stream to /dev/null, you'd likely have seen a message:

find: warning: ‘-name’ matches against basenames only, but the given pattern contains 
a directory separator (‘/’), thus the expression will evaluate to false all the time.

You probably want -path in place of -name:

find / -path /proc -prune -o -newermt "@$eptime" -printf '%T+\t%s\t%p\n' 2>/dev/null | sort -r

(note the absence of a trailing / on /proc).

Stephen avatar
cn flag
Thank you for your answer. -path instead of -name worked. :)
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.