What command lists the files created in a specific month and readable for the owner?
up vote
1
down vote
favorite
I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.
I know I'm supposed to use
ls -l
and I will use |
somewhere in it but not sure what comes before the pipe and what after.
linux command-line terminal
migrated from stackoverflow.com Sep 13 '12 at 21:03
This question came from our site for professional and enthusiast programmers.
add a comment |
up vote
1
down vote
favorite
I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.
I know I'm supposed to use
ls -l
and I will use |
somewhere in it but not sure what comes before the pipe and what after.
linux command-line terminal
migrated from stackoverflow.com Sep 13 '12 at 21:03
This question came from our site for professional and enthusiast programmers.
3
You should look into thefind
command. Also, don't attempt to parsels
- see mywiki.wooledge.org/ParsingLs.
– ziesemer
Sep 13 '12 at 14:37
2
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
1
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46
add a comment |
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.
I know I'm supposed to use
ls -l
and I will use |
somewhere in it but not sure what comes before the pipe and what after.
linux command-line terminal
I am supposed to find the command that lists all the files that are created in September and readable for the owner. Also explain how the command works.
I know I'm supposed to use
ls -l
and I will use |
somewhere in it but not sure what comes before the pipe and what after.
linux command-line terminal
linux command-line terminal
edited Dec 14 '15 at 6:32
tinlyx
61331532
61331532
asked Sep 13 '12 at 14:35
bangalo
migrated from stackoverflow.com Sep 13 '12 at 21:03
This question came from our site for professional and enthusiast programmers.
migrated from stackoverflow.com Sep 13 '12 at 21:03
This question came from our site for professional and enthusiast programmers.
3
You should look into thefind
command. Also, don't attempt to parsels
- see mywiki.wooledge.org/ParsingLs.
– ziesemer
Sep 13 '12 at 14:37
2
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
1
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46
add a comment |
3
You should look into thefind
command. Also, don't attempt to parsels
- see mywiki.wooledge.org/ParsingLs.
– ziesemer
Sep 13 '12 at 14:37
2
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
1
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46
3
3
You should look into the
find
command. Also, don't attempt to parse ls
- see mywiki.wooledge.org/ParsingLs.– ziesemer
Sep 13 '12 at 14:37
You should look into the
find
command. Also, don't attempt to parse ls
- see mywiki.wooledge.org/ParsingLs.– ziesemer
Sep 13 '12 at 14:37
2
2
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
1
1
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46
add a comment |
3 Answers
3
active
oldest
votes
up vote
0
down vote
For the date range you can use a trick. First create two dummy files with touch like this:
touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept
As you can check they have now desired creation dates:
$ ls -l 1sept 30sept
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept
Now you are ready to go with the final command:
find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'
A bit of exmplanation:
- -type f search for files only
- -newer ! -and -newer using dummy files as template set dates range you like
- -exec fires a command on every found file written as {} ;
- stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name
- grep '^.r' filter results with regular exception to show only lines starting from
<anycharacter>r, so checks if read access by the file owner is granted
Except thatls -l | grep "^r.*Sep"
will have the same result and is much faster.
– mikebabcock
Sep 15 '12 at 13:50
add a comment |
up vote
0
down vote
ls -lh
should list files in human readable long format (depending on your shell).
Now, you want to grep
(that's a filter program) for the ones that match what you're looking for.
For example, to find all the files that say david and that were made in 2011, I could use:
ls -lh | grep "david" | grep "2011"
(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).
In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh
and you should be able to make your own grep command that works.
add a comment |
up vote
-1
down vote
Try this one. Hope it will help:
ls -la | grep -e "Sep"
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
For the date range you can use a trick. First create two dummy files with touch like this:
touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept
As you can check they have now desired creation dates:
$ ls -l 1sept 30sept
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept
Now you are ready to go with the final command:
find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'
A bit of exmplanation:
- -type f search for files only
- -newer ! -and -newer using dummy files as template set dates range you like
- -exec fires a command on every found file written as {} ;
- stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name
- grep '^.r' filter results with regular exception to show only lines starting from
<anycharacter>r, so checks if read access by the file owner is granted
Except thatls -l | grep "^r.*Sep"
will have the same result and is much faster.
– mikebabcock
Sep 15 '12 at 13:50
add a comment |
up vote
0
down vote
For the date range you can use a trick. First create two dummy files with touch like this:
touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept
As you can check they have now desired creation dates:
$ ls -l 1sept 30sept
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept
Now you are ready to go with the final command:
find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'
A bit of exmplanation:
- -type f search for files only
- -newer ! -and -newer using dummy files as template set dates range you like
- -exec fires a command on every found file written as {} ;
- stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name
- grep '^.r' filter results with regular exception to show only lines starting from
<anycharacter>r, so checks if read access by the file owner is granted
Except thatls -l | grep "^r.*Sep"
will have the same result and is much faster.
– mikebabcock
Sep 15 '12 at 13:50
add a comment |
up vote
0
down vote
up vote
0
down vote
For the date range you can use a trick. First create two dummy files with touch like this:
touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept
As you can check they have now desired creation dates:
$ ls -l 1sept 30sept
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept
Now you are ready to go with the final command:
find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'
A bit of exmplanation:
- -type f search for files only
- -newer ! -and -newer using dummy files as template set dates range you like
- -exec fires a command on every found file written as {} ;
- stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name
- grep '^.r' filter results with regular exception to show only lines starting from
<anycharacter>r, so checks if read access by the file owner is granted
For the date range you can use a trick. First create two dummy files with touch like this:
touch -t 201209010000 /tmp/1sept
touch -t 201209302359 /tmp/30sept
As you can check they have now desired creation dates:
$ ls -l 1sept 30sept
-rw-rw-r-- 1 topr topr 0 Sep 1 00:00 1sept
-rw-rw-r-- 1 topr topr 0 Sep 30 2012 30sept
Now you are ready to go with the final command:
find /thepath/you/like -type f -newer /tmp/1sept -and ! -newer /tmp/30sept -exec stat -c '%A %n' {} ; | grep '^.r'
A bit of exmplanation:
- -type f search for files only
- -newer ! -and -newer using dummy files as template set dates range you like
- -exec fires a command on every found file written as {} ;
- stat command prints info about the file, %A means human readable access rights string like -rw-rw-r-- and %n prints file name
- grep '^.r' filter results with regular exception to show only lines starting from
<anycharacter>r, so checks if read access by the file owner is granted
edited Sep 14 '12 at 12:40
answered Sep 14 '12 at 12:35
topr
547410
547410
Except thatls -l | grep "^r.*Sep"
will have the same result and is much faster.
– mikebabcock
Sep 15 '12 at 13:50
add a comment |
Except thatls -l | grep "^r.*Sep"
will have the same result and is much faster.
– mikebabcock
Sep 15 '12 at 13:50
Except that
ls -l | grep "^r.*Sep"
will have the same result and is much faster.– mikebabcock
Sep 15 '12 at 13:50
Except that
ls -l | grep "^r.*Sep"
will have the same result and is much faster.– mikebabcock
Sep 15 '12 at 13:50
add a comment |
up vote
0
down vote
ls -lh
should list files in human readable long format (depending on your shell).
Now, you want to grep
(that's a filter program) for the ones that match what you're looking for.
For example, to find all the files that say david and that were made in 2011, I could use:
ls -lh | grep "david" | grep "2011"
(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).
In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh
and you should be able to make your own grep command that works.
add a comment |
up vote
0
down vote
ls -lh
should list files in human readable long format (depending on your shell).
Now, you want to grep
(that's a filter program) for the ones that match what you're looking for.
For example, to find all the files that say david and that were made in 2011, I could use:
ls -lh | grep "david" | grep "2011"
(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).
In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh
and you should be able to make your own grep command that works.
add a comment |
up vote
0
down vote
up vote
0
down vote
ls -lh
should list files in human readable long format (depending on your shell).
Now, you want to grep
(that's a filter program) for the ones that match what you're looking for.
For example, to find all the files that say david and that were made in 2011, I could use:
ls -lh | grep "david" | grep "2011"
(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).
In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh
and you should be able to make your own grep command that works.
ls -lh
should list files in human readable long format (depending on your shell).
Now, you want to grep
(that's a filter program) for the ones that match what you're looking for.
For example, to find all the files that say david and that were made in 2011, I could use:
ls -lh | grep "david" | grep "2011"
(Yes, there are faster, easier ways to do this, but the idea is to be simplistic for the asker).
In your case, you want to filter both that first block of text for the readable bit being set and the date being in September. Take a look at the output from ls -lh
and you should be able to make your own grep command that works.
edited Sep 14 '12 at 13:06
jokerdino
2,18711832
2,18711832
answered Sep 13 '12 at 21:15
mikebabcock
929510
929510
add a comment |
add a comment |
up vote
-1
down vote
Try this one. Hope it will help:
ls -la | grep -e "Sep"
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
add a comment |
up vote
-1
down vote
Try this one. Hope it will help:
ls -la | grep -e "Sep"
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
add a comment |
up vote
-1
down vote
up vote
-1
down vote
Try this one. Hope it will help:
ls -la | grep -e "Sep"
Try this one. Hope it will help:
ls -la | grep -e "Sep"
edited May 10 at 8:27
Anaksunaman
5,11321222
5,11321222
answered May 10 at 8:12
Ikram
1
1
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
add a comment |
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
2
2
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
Please consider editing this answer to explain what this command is doing and why you are suggesting it. The asker clearly is unsure of what to do and why. Your guidance would likely be extremely helpful.
– Anaksunaman
May 10 at 8:30
add a comment |
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f473842%2fwhat-command-lists-the-files-created-in-a-specific-month-and-readable-for-the-ow%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
3
You should look into the
find
command. Also, don't attempt to parsels
- see mywiki.wooledge.org/ParsingLs.– ziesemer
Sep 13 '12 at 14:37
2
I guess it isn't against the rules to ask StackExchange people to do your homework for you. But if you don't do it yourself, how are you going to learn?
– Isaac Rabinovitch
Sep 13 '12 at 21:55
1
First, bear in mind that when you deal with timestamps on files, what you generally are dealing with is 'modification time'. There are two other times: 'change time' and 'access time'. These are also known respectively as mtime, ctime and atime. There is no 'creation' time in Unix filesystems (or at least, not on any that I have seen)
– Cameron Kerr
Sep 10 '14 at 9:42
The 'info' page for the 'touch' command is useful in explaining 'change time': "The inode change time represents the time when the file's meta-information last changed. One common example of this is when the permissions of a file change." It has some other relevant things to say also. Another useful 'info' page is the 'date' command -- it will give you ideas of how you can specify the --date argument. Reading 'info' pages is sometimes very useful...
– Cameron Kerr
Sep 10 '14 at 9:46