Determine the files/directories changed as a result of running a command
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
If I run a command in bash, is there any way to determine which files and directories were modified as a result of running that command?
For example, if i run:
export $MYDIR="/home/users/myuser/"
touch $MY_DIR/*
I would like to be able to list the files that were modified:
/home/users/myuser/file1
/home/users/myuser/file2
/home/users/myuser/file3
But not specifically for touch
. I would like the solution to be general for any command.
Is this possible?
linux bash shell
add a comment |Â
up vote
2
down vote
favorite
If I run a command in bash, is there any way to determine which files and directories were modified as a result of running that command?
For example, if i run:
export $MYDIR="/home/users/myuser/"
touch $MY_DIR/*
I would like to be able to list the files that were modified:
/home/users/myuser/file1
/home/users/myuser/file2
/home/users/myuser/file3
But not specifically for touch
. I would like the solution to be general for any command.
Is this possible?
linux bash shell
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
If I run a command in bash, is there any way to determine which files and directories were modified as a result of running that command?
For example, if i run:
export $MYDIR="/home/users/myuser/"
touch $MY_DIR/*
I would like to be able to list the files that were modified:
/home/users/myuser/file1
/home/users/myuser/file2
/home/users/myuser/file3
But not specifically for touch
. I would like the solution to be general for any command.
Is this possible?
linux bash shell
If I run a command in bash, is there any way to determine which files and directories were modified as a result of running that command?
For example, if i run:
export $MYDIR="/home/users/myuser/"
touch $MY_DIR/*
I would like to be able to list the files that were modified:
/home/users/myuser/file1
/home/users/myuser/file2
/home/users/myuser/file3
But not specifically for touch
. I would like the solution to be general for any command.
Is this possible?
linux bash shell
linux bash shell
asked Aug 21 at 6:33
moebius
1135
1135
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
2
down vote
accepted
There are a couple of tools which I quite like for this kind of use case:
maybe
will run a command, but fake any modification to the file system (pretend it succeeded without performing it, and log it), then display a list of all the changes; you can then decide whether to run the command again â itâÂÂs not perfect, see the list of issues, but itâÂÂs good enough in many cases;
LoggedFS provides a logging file system overlay, which lets all changes to a file system go through but logs them, in a configurable manner (see LoggedFS configuration file syntax for details).
Other tools commonly used to trace file system operations include inotifywait
and auditd
; see Linux file access monitoring for details.
add a comment |Â
up vote
1
down vote
For a basic / simplistic solution, how about creating a file first, and then, after your operation, running a find
to display files newer than said file ?
touch /tmp/myfile
( do stuff )
find $MY_DIR -newer /tmp/myfile
As @roaima points out, this only address your "which files and directories were modified as a result" requirement : it would not identify files that were removed.
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it'szsh
syntax. Withbash
(see tag in OP's question), you'd needfind "$MY_DIR"
.find $MY_DIR
would only make sense inbash
if$MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)
â Stéphane Chazelas
Aug 27 at 18:18
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
There are a couple of tools which I quite like for this kind of use case:
maybe
will run a command, but fake any modification to the file system (pretend it succeeded without performing it, and log it), then display a list of all the changes; you can then decide whether to run the command again â itâÂÂs not perfect, see the list of issues, but itâÂÂs good enough in many cases;
LoggedFS provides a logging file system overlay, which lets all changes to a file system go through but logs them, in a configurable manner (see LoggedFS configuration file syntax for details).
Other tools commonly used to trace file system operations include inotifywait
and auditd
; see Linux file access monitoring for details.
add a comment |Â
up vote
2
down vote
accepted
There are a couple of tools which I quite like for this kind of use case:
maybe
will run a command, but fake any modification to the file system (pretend it succeeded without performing it, and log it), then display a list of all the changes; you can then decide whether to run the command again â itâÂÂs not perfect, see the list of issues, but itâÂÂs good enough in many cases;
LoggedFS provides a logging file system overlay, which lets all changes to a file system go through but logs them, in a configurable manner (see LoggedFS configuration file syntax for details).
Other tools commonly used to trace file system operations include inotifywait
and auditd
; see Linux file access monitoring for details.
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
There are a couple of tools which I quite like for this kind of use case:
maybe
will run a command, but fake any modification to the file system (pretend it succeeded without performing it, and log it), then display a list of all the changes; you can then decide whether to run the command again â itâÂÂs not perfect, see the list of issues, but itâÂÂs good enough in many cases;
LoggedFS provides a logging file system overlay, which lets all changes to a file system go through but logs them, in a configurable manner (see LoggedFS configuration file syntax for details).
Other tools commonly used to trace file system operations include inotifywait
and auditd
; see Linux file access monitoring for details.
There are a couple of tools which I quite like for this kind of use case:
maybe
will run a command, but fake any modification to the file system (pretend it succeeded without performing it, and log it), then display a list of all the changes; you can then decide whether to run the command again â itâÂÂs not perfect, see the list of issues, but itâÂÂs good enough in many cases;
LoggedFS provides a logging file system overlay, which lets all changes to a file system go through but logs them, in a configurable manner (see LoggedFS configuration file syntax for details).
Other tools commonly used to trace file system operations include inotifywait
and auditd
; see Linux file access monitoring for details.
answered Aug 21 at 8:17
Stephen Kitt
146k22320386
146k22320386
add a comment |Â
add a comment |Â
up vote
1
down vote
For a basic / simplistic solution, how about creating a file first, and then, after your operation, running a find
to display files newer than said file ?
touch /tmp/myfile
( do stuff )
find $MY_DIR -newer /tmp/myfile
As @roaima points out, this only address your "which files and directories were modified as a result" requirement : it would not identify files that were removed.
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it'szsh
syntax. Withbash
(see tag in OP's question), you'd needfind "$MY_DIR"
.find $MY_DIR
would only make sense inbash
if$MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)
â Stéphane Chazelas
Aug 27 at 18:18
add a comment |Â
up vote
1
down vote
For a basic / simplistic solution, how about creating a file first, and then, after your operation, running a find
to display files newer than said file ?
touch /tmp/myfile
( do stuff )
find $MY_DIR -newer /tmp/myfile
As @roaima points out, this only address your "which files and directories were modified as a result" requirement : it would not identify files that were removed.
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it'szsh
syntax. Withbash
(see tag in OP's question), you'd needfind "$MY_DIR"
.find $MY_DIR
would only make sense inbash
if$MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)
â Stéphane Chazelas
Aug 27 at 18:18
add a comment |Â
up vote
1
down vote
up vote
1
down vote
For a basic / simplistic solution, how about creating a file first, and then, after your operation, running a find
to display files newer than said file ?
touch /tmp/myfile
( do stuff )
find $MY_DIR -newer /tmp/myfile
As @roaima points out, this only address your "which files and directories were modified as a result" requirement : it would not identify files that were removed.
For a basic / simplistic solution, how about creating a file first, and then, after your operation, running a find
to display files newer than said file ?
touch /tmp/myfile
( do stuff )
find $MY_DIR -newer /tmp/myfile
As @roaima points out, this only address your "which files and directories were modified as a result" requirement : it would not identify files that were removed.
edited Aug 21 at 8:37
answered Aug 21 at 8:10
steve
12.9k22149
12.9k22149
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it'szsh
syntax. Withbash
(see tag in OP's question), you'd needfind "$MY_DIR"
.find $MY_DIR
would only make sense inbash
if$MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)
â Stéphane Chazelas
Aug 27 at 18:18
add a comment |Â
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it'szsh
syntax. Withbash
(see tag in OP's question), you'd needfind "$MY_DIR"
.find $MY_DIR
would only make sense inbash
if$MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)
â Stéphane Chazelas
Aug 27 at 18:18
1
1
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
You'd need a "before and after" to catch a tool that removed files
â roaima
Aug 21 at 8:18
Note that it's
zsh
syntax. With bash
(see tag in OP's question), you'd need find "$MY_DIR"
. find $MY_DIR
would only make sense in bash
if $MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)â Stéphane Chazelas
Aug 27 at 18:18
Note that it's
zsh
syntax. With bash
(see tag in OP's question), you'd need find "$MY_DIR"
. find $MY_DIR
would only make sense in bash
if $MY_DIR
was meant to contain a $IFS-separated list of file patterns that you intended to expand. (:-b)â Stéphane Chazelas
Aug 27 at 18:18
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f463785%2fdetermine-the-files-directories-changed-as-a-result-of-running-a-command%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password