In: Computer Science
Explore how to use various combinations of switches for the DIR command to find files/folders in C:\WINDOWS\SYSTEM32 directory.
Objective: List each search line by line and give then the
command used to discover the following and include a small sample
of your discovery.
(Example: How would you pause the display? DIR /P and give two
files discovered) What switches would you use to find.
Example of structure:
#!/bin/bash
# EOQ-111.sh maw 2/24/20XX
# Archive class work and set all files to read only and make a list
with a shell script
echo Starting archiving 111
mkdir ~/archives/EOQ-111
cp ~/CIS111/* ~/archives/EOQ-111
ls ~/archives/EOQ-111 > EOQ-111.txt
chmod 400 ~/archives/EOQ-111/*
echo End of program
(No screenshots please)
A) What's the oldest file?
B) What's the youngest file?
C) What's the largest file?
D) What's the smallest file?
E) How many .exe files there are?
F) How would you show only directories in lower case?
G) How would you show only files names by extension?
H) How would you show any hidden files?
A) What's the oldest file?
dir /o:d | head -n 1
/o Sorts the output according to sortorder, which can be any combination of the following values:n,e,g,s,d
/d By date/time, oldest first
B)What's the youngest file?
dir /o:d | tail -n 1
/o Sorts the output according to sortorder, which can be any combination of the following values:n,e,g,s,d
/d By date/time, oldest first
C)What's the largest file?
dir /o:s | tail -n 1
/o Sorts the output according to sortorder, which can be any combination of the following values:n,e,g,s,d
By size, smallest first
D) What's the smallest file?
dir /o:s | head -n 1
/o Sorts the output according to sortorder, which can be any combination of the following values:n,e,g,s,d
By size, smallest first
E)How many .exe files there are?
dir /s /b *.exe | findstr /e .exe
/s Lists the files in the folder and also the ones in the subfolders recursively.
/b Lists the subfolders/files names in bare format.
findstr /e : Matches the pattern .exe if at the end of a line
F)How would you show only directories in lower case?
dir /ad /L
d:Displays all directories in the current path
l:display lowercase
G) How would you show only files names by extension?
dir *.* /b /s
*.*=It will display all the files in the current directory with any extension.
/s=Lists every occurrence of the specified file name within the specified directory and all subdirectories.
/b=Displays a bare list of directories and files, with no additional information. The /b parameter overrides /w.
H) How would you show any hidden files?
dir /a:h /b /s
/a:h=displays hidden files
/s=Lists every occurrence of the specified file name within the specified directory and all subdirectories.
/b=Displays a bare list of directories and files, with no additional information. The /b parameter overrides /w.