Lab No 4 Finding Files After completing this lab students wi
Solution
1. Which command will list all the files that have a timestamp?
As we assumed, the digits included in the file names are dates,
we are supposed to list all the file names, that include digits in it.
So, to do that, the command is:
ls *[0-9]*
2. Which command will list all the \"dnf\" and \"mail\" files that have a timestamp?
dnf mails start with dnf, and mail files start with mail, so list all dnf, and mail files,
the command is:
ls {dnf*,mail*}
But this will list all the files. To further filter the files that are with time stamp,
now use the command:
ls {dnf*,mail*} | grep \"[0-9]\"
This will list all the dnf and mail files, and among those files, it will display only
files that have timestamps in it.
3. Which command will list all the \"dnf\" files that do not have a timestamp?
ls dnf* will list all the dnf files.
And to further filter the files that do not have a time stamp, lets use the grep command.
The grep command with -v option will list all the file names, except the names that match the pattern.
So, the command is:
ls dnf* | grep -v \"[0-9]\"
4. Execute a command that will ensure that all files in the wildcards directory can be only
be read and written by the owner. Include this command in your report.
If you are readily in wildcards directory, the command to ensure all the files have only
read and write permissions to the owner is:
chmod 600 *
