SlideShare a Scribd company logo
1 of 15
$ filecount /etc
/etc: 153 ordinary 3 executable 7 links 124 directories
$ echo $?
0
$ filecount /dev
/dev: 170 ordinary 0 executable 8 links 17 directories
$ echo $?
0
$ filecount /
/: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ filecount /etc /dev /
/etc: 153 ordinary 3 executable 7 links 124 directories
/dev: 170 ordinary 0 executable 8 links 17 directories
/: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ cd /
$ filecount
.: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ filecount -f -x -l -d
.: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ filecount -f -x -l -d /
/: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ filecount -l -d -x -f / /dev
/: 1 ordinary 0 executable 0 links 20 directories
/dev: 170 ordinary 0 executable 8 links 17 directories
$ echo $?
0
$ filecount -z
filecount: Illegal option -- z
Usage: filecount [-dflx] [directory ...]
$ echo $?
1
$ filecount -f / -z /dev
/: 1 ordinary
filecount: Invalid directory: -z
$ echo $?
2
$ filecount -x /bin
/bin: 22 executable
$ echo $?
0
$ filecount -l /usr/bin
/usr/bin: 459 links
$ echo $?
0
$ filecount -f -x /usr/sbin
/usr/sbin: 10 ordinary 445 executable
$ echo $?
0
$ filecount -f /usr/include
/usr/include: 130 ordinary
$ echo $?
0
$ filecount -f /usr/include /usr/lib
/usr/include: 130 ordinary
/usr/lib: 15 ordinary
$ echo $?
0
$ filecount -l
.: 0 links
$ echo $?
0
$ filecount .
.: 1 ordinary 0 executable 0 links 20 directories
$ echo $?
0
$ cd /etc
$ filecount -l -d -f
.: 153 ordinary 7 links 124 directories
$ echo $?
0
$ filecount -f -x /usr/include /usr/sbin/
/usr/include: 130 ordinary 0 executable
/usr/sbin/: 10 ordinary 445 executable
$ echo $?
0
$ filecount /lost
filecount: Invalid directory: /lost
$ echo $?
2
$ filecount / /lost
/: 1 ordinary 0 executable 0 links 20 directories
filecount: Invalid directory: /lost
$ echo $?
2
$ filecount /lost /
filecount: Invalid directory: /lost
$ echo $?
2
$ filecount /usr/bin/grep
filecount: Invalid directory: /usr/bin/grep
$ echo $?
2
$ filecount /u*
/usr: 0 ordinary 0 executable 1 links 11 directories
$ echo $?
0
$ filecount /bin
/bin: 0 ordinary 22 executable 112 links 0 directories
$ echo $?
0
$ filecount /b*
/bin: 0 ordinary 22 executable 112 links 0 directories
/boot: 19 ordinary 0 executable 3 links 3 directories
$ echo $?
0
$ filecount /usr/include/s*
filecount: Invalid directory: /usr/include/sched.h
$ echo $?
2
$ filecount -z -z
filecount: Illegal option -- z
Usage: filecount [-dflx] [directory ...]
$ echo $?
1
$ filecount -f -f /usr/lib
/usr/lib: 15 ordinary
$ echo $?
0
$ filecount -f /usr/lib/ /usr/sbin/ -f
/usr/lib/: 15 ordinary
/usr/sbin/: 10 ordinary
filecount: Invalid directory: -f
$ echo $?
2
$ filecount -f -x --
.: 153 ordinary 3 executable
$ echo $?
0
$ filecount -f -x -- -somedir
filecount: Invalid directory: -somedir
$ echo $?
2
$ filecount -f -x -- / -somedir
/: 1 ordinary 0 executable
filecount: Invalid directory: -somedir
$ echo $?
2
Write a Korn shell script filecount which counts the number of
ordinary files (defined as everything except the following),
number
of executable files, number of links, and number of directories
in one or more directories which are provided as commandline
arguments.
Requirements
? The above counts include dot files, except that . and .. are not
included in the directory count (investigate the -A option to ls).
? Files in sub-directories are not included in the counts.
? The distinction between file types is the same as that of ls -F.
? If the script is invoked with no directory name provided, it
must work
on the current directory. Otherwise, it must produce a single
line of
output for each directory it processes, as in the following
sample (on
fictitious locations):
1 $ ./filecount
2 . : 10 ordinary 9 executable 3 links 5 directories
3 $
4 $ ./filecount courses tmp
5 courses: 2 ordinary 8 executable 7 links 42 directories
6 tmp : 8 ordinary 17 executable 5 links 51 directories
? The script must support the following command-line options:
-f: include the count of ordinary files in the output
-x: include the count of executable files in the output
-l: include the count of links in the output
-d: include the count of directories in the output
If any of these options are specified when the script is called,
then only
the requested totals must be printed for each directory.
? If an invalid option <option> is given, the script must print
./filecount: Illegal option: <option> and a usage message
to stderr and halt with a exit status 1 as shown below.
1 $ ./filecount ?t
2 ./filecount: Illegal option ?t
3 Usage : filecount [?dflx] [directory . . . ]
4 $ echo $?
5 1
? If an invalid directory <directory> is given, the script must
print
./filecount: Invalid directory: <directory> and a
usage message to stderr and halt with a exit status 2.
1 $ ./filecount somedir
2 ./filecount: Invalid directory: somedir
3 Usage : filecount [?dflx] [directory . . . ]
4 $ echo $?
5 2
? The script must execute using the Korn shell interpreter (ksh).
You
may not use C, C++, Perl, Python, Ruby, or any similar
language.
? The script must run at the command line as: ./filecount
[-dflx] [directory ...].
? The script must have -rwxr-x-- permission.
? The script must terminate with a proper exit statement.
? Do not use any specific aspects of your environment within
the script.
In other words, use native Linux command names as opposed to
your
environment¡¯s aliases for those commands and do not rely on
any
specific aspect of your environment (e.g., values of particular
shell
variables).
? Each line of output must separate the directory from the
counts with
a single colon (:) followed by exactly two spaces. Delimit each
count
from its label with a single space and delimit each count label
pair
from each other with exactly two spaces (exactly as shown
above). Always
print the ordinary count first, followed by the executable count,
then the link count, and finally the directory count, if requested,
regardless
of the order in which the options are given on the command
line.
? Each line of output must not contain any leading and trailing
whitespace
or any extraneous text.
? All options must precede all directories on a command line.
? Use - to indicate the end of options.
? Options can be given as singletons (e.g., -x) or in any
combinations
(e.g., -fx, -xf, -fxld).
? The file counts are mutually-exclusive. One file must never be
counted twice. Anything that is not a directory, symbolic link,
or executable,
is an ordinary file.
? Executable files are to be counted as executable only, not
executable
and ordinary.
? The script must not create any new files or remove any
existing files.
? The script must not create any new directories or remove any
existing
directories.
You are encouraged to make creative use of the given tools
(grep, sed,
awk, and others) and string operators (i.e., do not reinvent the
wheel). Remember,
grep, sed, and awk can be used on shell variables (e.g., $(echo
$PATH | sed ¡¯s/:/2/g¡¯)). Also, explore getopts (though not
necessary),
ls -A, print -n, and print - -n. If designed properly, the
script required for this homework should occupy no more than
100 lines
of code.
$ filecount etcetc  153 ordinary  3 executable  7 links  124.docx

More Related Content

Similar to $ filecount etcetc 153 ordinary 3 executable 7 links 124.docx

50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)Rodrigo Maia
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsBITS
 
Quize on scripting shell
Quize on scripting shellQuize on scripting shell
Quize on scripting shelllebse123
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSMohamed Abdallah
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Ranjan Raja
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualKuntal Bhowmick
 
Using Unix
Using UnixUsing Unix
Using UnixDr.Ravi
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25Techvilla
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basicsManav Prasad
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting BasicsSudharsan S
 
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...Joachim Jacob
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1solgenomics
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginnersSuKyeong Jang
 

Similar to $ filecount etcetc 153 ordinary 3 executable 7 links 124.docx (20)

50 most frequently used unix
50 most frequently used unix50 most frequently used unix
50 most frequently used unix
 
Unix Basics For Testers
Unix Basics For TestersUnix Basics For Testers
Unix Basics For Testers
 
50 most frequently used unix linux commands (with examples)
50 most frequently used unix   linux commands (with examples)50 most frequently used unix   linux commands (with examples)
50 most frequently used unix linux commands (with examples)
 
Text mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformaticsText mining on the command line - Introduction to linux for bioinformatics
Text mining on the command line - Introduction to linux for bioinformatics
 
Quize on scripting shell
Quize on scripting shellQuize on scripting shell
Quize on scripting shell
 
Raspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OSRaspberry Pi - Lecture 2 Linux OS
Raspberry Pi - Lecture 2 Linux OS
 
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
 
Unix
UnixUnix
Unix
 
Basic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manualBasic shell programs assignment 1_solution_manual
Basic shell programs assignment 1_solution_manual
 
Using Unix
Using UnixUsing Unix
Using Unix
 
00-Review of Linux Basics
00-Review of Linux Basics00-Review of Linux Basics
00-Review of Linux Basics
 
Examples -partII
Examples -partIIExamples -partII
Examples -partII
 
Raspberry pi Part 25
Raspberry pi Part 25Raspberry pi Part 25
Raspberry pi Part 25
 
Unix shell scripting basics
Unix shell scripting basicsUnix shell scripting basics
Unix shell scripting basics
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
Part 5 of "Introduction to Linux for Bioinformatics": Working the command lin...
 
Linux And perl
Linux And perlLinux And perl
Linux And perl
 
SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1SGN Introduction to UNIX Command-line 2015 part 1
SGN Introduction to UNIX Command-line 2015 part 1
 
Linuxppt
LinuxpptLinuxppt
Linuxppt
 
Linux command for beginners
Linux command for beginnersLinux command for beginners
Linux command for beginners
 

More from mayank272369

NEW YORK STATE It is important to identify and develop vario.docx
NEW YORK STATE It is important to identify and develop vario.docxNEW YORK STATE It is important to identify and develop vario.docx
NEW YORK STATE It is important to identify and develop vario.docxmayank272369
 
Next, offer your perspective on transparency. In Chapter 3 of th.docx
Next, offer your perspective on transparency. In Chapter 3 of th.docxNext, offer your perspective on transparency. In Chapter 3 of th.docx
Next, offer your perspective on transparency. In Chapter 3 of th.docxmayank272369
 
New research suggests that the m ost effective executives .docx
New research suggests that the m ost effective executives .docxNew research suggests that the m ost effective executives .docx
New research suggests that the m ost effective executives .docxmayank272369
 
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docx
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docxNewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docx
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docxmayank272369
 
Negotiation StylesWe negotiate multiple times every day in e.docx
Negotiation StylesWe negotiate multiple times every day in e.docxNegotiation StylesWe negotiate multiple times every day in e.docx
Negotiation StylesWe negotiate multiple times every day in e.docxmayank272369
 
Neurological SystemThe nervous system is a collection of nerves .docx
Neurological SystemThe nervous system is a collection of nerves .docxNeurological SystemThe nervous system is a collection of nerves .docx
Neurological SystemThe nervous system is a collection of nerves .docxmayank272369
 
Neuroleadership is an emerging trend in the field of management..docx
Neuroleadership is an emerging trend in the field of management..docxNeuroleadership is an emerging trend in the field of management..docx
Neuroleadership is an emerging trend in the field of management..docxmayank272369
 
Network security A firewall is a network security device tha.docx
Network security A firewall is a network security device tha.docxNetwork security A firewall is a network security device tha.docx
Network security A firewall is a network security device tha.docxmayank272369
 
Network Forensics Use the Internet or the Strayer Library to.docx
Network Forensics Use the Internet or the Strayer Library to.docxNetwork Forensics Use the Internet or the Strayer Library to.docx
Network Forensics Use the Internet or the Strayer Library to.docxmayank272369
 
Negotiation Process in the International ArenaNegotiation is.docx
Negotiation Process in the International ArenaNegotiation is.docxNegotiation Process in the International ArenaNegotiation is.docx
Negotiation Process in the International ArenaNegotiation is.docxmayank272369
 
Needs to be 150 word min. Perform a scholarly search (using Pu.docx
Needs to be 150 word min. Perform a scholarly search (using Pu.docxNeeds to be 150 word min. Perform a scholarly search (using Pu.docx
Needs to be 150 word min. Perform a scholarly search (using Pu.docxmayank272369
 
Needing assistance with powerpoint presentation for Sociology in the.docx
Needing assistance with powerpoint presentation for Sociology in the.docxNeeding assistance with powerpoint presentation for Sociology in the.docx
Needing assistance with powerpoint presentation for Sociology in the.docxmayank272369
 
Need to write essay on 1000 words about Guns and Crimes , in context.docx
Need to write essay on 1000 words about Guns and Crimes , in context.docxNeed to write essay on 1000 words about Guns and Crimes , in context.docx
Need to write essay on 1000 words about Guns and Crimes , in context.docxmayank272369
 
Need Research Paper related to the course Related topic in the.docx
Need Research Paper related to the course Related topic in the.docxNeed Research Paper related to the course Related topic in the.docx
Need Research Paper related to the course Related topic in the.docxmayank272369
 
Need it in about 12 hours. There are 3 docx file each one of.docx
Need it in about 12 hours. There are 3 docx file each one of.docxNeed it in about 12 hours. There are 3 docx file each one of.docx
Need it in about 12 hours. There are 3 docx file each one of.docxmayank272369
 
Need plagiarism very important Select one type of cryptography o.docx
Need plagiarism very important Select one type of cryptography o.docxNeed plagiarism very important Select one type of cryptography o.docx
Need plagiarism very important Select one type of cryptography o.docxmayank272369
 
Need the below with in 24 hours.Provide 2 references,500 words.docx
Need the below with in 24 hours.Provide 2 references,500 words.docxNeed the below with in 24 hours.Provide 2 references,500 words.docx
Need the below with in 24 hours.Provide 2 references,500 words.docxmayank272369
 
Need it within 12-14 hours of time.One paragraph with 300 words .docx
Need it within 12-14 hours of time.One paragraph with 300 words .docxNeed it within 12-14 hours of time.One paragraph with 300 words .docx
Need it within 12-14 hours of time.One paragraph with 300 words .docxmayank272369
 
Need it to be 300 words. Two paragraphs only. What would you co.docx
Need it to be 300 words. Two paragraphs only.  What would you co.docxNeed it to be 300 words. Two paragraphs only.  What would you co.docx
Need it to be 300 words. Two paragraphs only. What would you co.docxmayank272369
 
Need it for tomorrow morning!!!!For your synthesis essay, yo.docx
Need it for tomorrow morning!!!!For your synthesis essay, yo.docxNeed it for tomorrow morning!!!!For your synthesis essay, yo.docx
Need it for tomorrow morning!!!!For your synthesis essay, yo.docxmayank272369
 

More from mayank272369 (20)

NEW YORK STATE It is important to identify and develop vario.docx
NEW YORK STATE It is important to identify and develop vario.docxNEW YORK STATE It is important to identify and develop vario.docx
NEW YORK STATE It is important to identify and develop vario.docx
 
Next, offer your perspective on transparency. In Chapter 3 of th.docx
Next, offer your perspective on transparency. In Chapter 3 of th.docxNext, offer your perspective on transparency. In Chapter 3 of th.docx
Next, offer your perspective on transparency. In Chapter 3 of th.docx
 
New research suggests that the m ost effective executives .docx
New research suggests that the m ost effective executives .docxNew research suggests that the m ost effective executives .docx
New research suggests that the m ost effective executives .docx
 
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docx
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docxNewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docx
NewFCFF2StageTwo-Stage FCFF Discount ModelThis model is designed t.docx
 
Negotiation StylesWe negotiate multiple times every day in e.docx
Negotiation StylesWe negotiate multiple times every day in e.docxNegotiation StylesWe negotiate multiple times every day in e.docx
Negotiation StylesWe negotiate multiple times every day in e.docx
 
Neurological SystemThe nervous system is a collection of nerves .docx
Neurological SystemThe nervous system is a collection of nerves .docxNeurological SystemThe nervous system is a collection of nerves .docx
Neurological SystemThe nervous system is a collection of nerves .docx
 
Neuroleadership is an emerging trend in the field of management..docx
Neuroleadership is an emerging trend in the field of management..docxNeuroleadership is an emerging trend in the field of management..docx
Neuroleadership is an emerging trend in the field of management..docx
 
Network security A firewall is a network security device tha.docx
Network security A firewall is a network security device tha.docxNetwork security A firewall is a network security device tha.docx
Network security A firewall is a network security device tha.docx
 
Network Forensics Use the Internet or the Strayer Library to.docx
Network Forensics Use the Internet or the Strayer Library to.docxNetwork Forensics Use the Internet or the Strayer Library to.docx
Network Forensics Use the Internet or the Strayer Library to.docx
 
Negotiation Process in the International ArenaNegotiation is.docx
Negotiation Process in the International ArenaNegotiation is.docxNegotiation Process in the International ArenaNegotiation is.docx
Negotiation Process in the International ArenaNegotiation is.docx
 
Needs to be 150 word min. Perform a scholarly search (using Pu.docx
Needs to be 150 word min. Perform a scholarly search (using Pu.docxNeeds to be 150 word min. Perform a scholarly search (using Pu.docx
Needs to be 150 word min. Perform a scholarly search (using Pu.docx
 
Needing assistance with powerpoint presentation for Sociology in the.docx
Needing assistance with powerpoint presentation for Sociology in the.docxNeeding assistance with powerpoint presentation for Sociology in the.docx
Needing assistance with powerpoint presentation for Sociology in the.docx
 
Need to write essay on 1000 words about Guns and Crimes , in context.docx
Need to write essay on 1000 words about Guns and Crimes , in context.docxNeed to write essay on 1000 words about Guns and Crimes , in context.docx
Need to write essay on 1000 words about Guns and Crimes , in context.docx
 
Need Research Paper related to the course Related topic in the.docx
Need Research Paper related to the course Related topic in the.docxNeed Research Paper related to the course Related topic in the.docx
Need Research Paper related to the course Related topic in the.docx
 
Need it in about 12 hours. There are 3 docx file each one of.docx
Need it in about 12 hours. There are 3 docx file each one of.docxNeed it in about 12 hours. There are 3 docx file each one of.docx
Need it in about 12 hours. There are 3 docx file each one of.docx
 
Need plagiarism very important Select one type of cryptography o.docx
Need plagiarism very important Select one type of cryptography o.docxNeed plagiarism very important Select one type of cryptography o.docx
Need plagiarism very important Select one type of cryptography o.docx
 
Need the below with in 24 hours.Provide 2 references,500 words.docx
Need the below with in 24 hours.Provide 2 references,500 words.docxNeed the below with in 24 hours.Provide 2 references,500 words.docx
Need the below with in 24 hours.Provide 2 references,500 words.docx
 
Need it within 12-14 hours of time.One paragraph with 300 words .docx
Need it within 12-14 hours of time.One paragraph with 300 words .docxNeed it within 12-14 hours of time.One paragraph with 300 words .docx
Need it within 12-14 hours of time.One paragraph with 300 words .docx
 
Need it to be 300 words. Two paragraphs only. What would you co.docx
Need it to be 300 words. Two paragraphs only.  What would you co.docxNeed it to be 300 words. Two paragraphs only.  What would you co.docx
Need it to be 300 words. Two paragraphs only. What would you co.docx
 
Need it for tomorrow morning!!!!For your synthesis essay, yo.docx
Need it for tomorrow morning!!!!For your synthesis essay, yo.docxNeed it for tomorrow morning!!!!For your synthesis essay, yo.docx
Need it for tomorrow morning!!!!For your synthesis essay, yo.docx
 

Recently uploaded

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfakmcokerachita
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docxPoojaSen20
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 

Recently uploaded (20)

Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Class 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdfClass 11 Legal Studies Ch-1 Concept of State .pdf
Class 11 Legal Studies Ch-1 Concept of State .pdf
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
mini mental status format.docx
mini    mental       status     format.docxmini    mental       status     format.docx
mini mental status format.docx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 

$ filecount etcetc 153 ordinary 3 executable 7 links 124.docx

  • 1. $ filecount /etc /etc: 153 ordinary 3 executable 7 links 124 directories $ echo $? 0 $ filecount /dev /dev: 170 ordinary 0 executable 8 links 17 directories $ echo $? 0 $ filecount / /: 1 ordinary 0 executable 0 links 20 directories $ echo $? 0 $ filecount /etc /dev / /etc: 153 ordinary 3 executable 7 links 124 directories /dev: 170 ordinary 0 executable 8 links 17 directories /: 1 ordinary 0 executable 0 links 20 directories $ echo $?
  • 2. 0 $ cd / $ filecount .: 1 ordinary 0 executable 0 links 20 directories $ echo $? 0 $ filecount -f -x -l -d .: 1 ordinary 0 executable 0 links 20 directories $ echo $? 0 $ filecount -f -x -l -d / /: 1 ordinary 0 executable 0 links 20 directories $ echo $? 0 $ filecount -l -d -x -f / /dev /: 1 ordinary 0 executable 0 links 20 directories /dev: 170 ordinary 0 executable 8 links 17 directories $ echo $?
  • 3. 0 $ filecount -z filecount: Illegal option -- z Usage: filecount [-dflx] [directory ...] $ echo $? 1 $ filecount -f / -z /dev /: 1 ordinary filecount: Invalid directory: -z $ echo $? 2 $ filecount -x /bin /bin: 22 executable $ echo $? 0 $ filecount -l /usr/bin /usr/bin: 459 links $ echo $?
  • 4. 0 $ filecount -f -x /usr/sbin /usr/sbin: 10 ordinary 445 executable $ echo $? 0 $ filecount -f /usr/include /usr/include: 130 ordinary $ echo $? 0 $ filecount -f /usr/include /usr/lib /usr/include: 130 ordinary /usr/lib: 15 ordinary $ echo $? 0 $ filecount -l .: 0 links $ echo $? 0
  • 5. $ filecount . .: 1 ordinary 0 executable 0 links 20 directories $ echo $? 0 $ cd /etc $ filecount -l -d -f .: 153 ordinary 7 links 124 directories $ echo $? 0 $ filecount -f -x /usr/include /usr/sbin/ /usr/include: 130 ordinary 0 executable /usr/sbin/: 10 ordinary 445 executable $ echo $? 0 $ filecount /lost filecount: Invalid directory: /lost $ echo $? 2
  • 6. $ filecount / /lost /: 1 ordinary 0 executable 0 links 20 directories filecount: Invalid directory: /lost $ echo $? 2 $ filecount /lost / filecount: Invalid directory: /lost $ echo $? 2 $ filecount /usr/bin/grep filecount: Invalid directory: /usr/bin/grep $ echo $? 2 $ filecount /u* /usr: 0 ordinary 0 executable 1 links 11 directories $ echo $? 0 $ filecount /bin
  • 7. /bin: 0 ordinary 22 executable 112 links 0 directories $ echo $? 0 $ filecount /b* /bin: 0 ordinary 22 executable 112 links 0 directories /boot: 19 ordinary 0 executable 3 links 3 directories $ echo $? 0 $ filecount /usr/include/s* filecount: Invalid directory: /usr/include/sched.h $ echo $? 2 $ filecount -z -z filecount: Illegal option -- z Usage: filecount [-dflx] [directory ...] $ echo $? 1 $ filecount -f -f /usr/lib
  • 8. /usr/lib: 15 ordinary $ echo $? 0 $ filecount -f /usr/lib/ /usr/sbin/ -f /usr/lib/: 15 ordinary /usr/sbin/: 10 ordinary filecount: Invalid directory: -f $ echo $? 2 $ filecount -f -x -- .: 153 ordinary 3 executable $ echo $? 0 $ filecount -f -x -- -somedir filecount: Invalid directory: -somedir $ echo $? 2 $ filecount -f -x -- / -somedir
  • 9. /: 1 ordinary 0 executable filecount: Invalid directory: -somedir $ echo $? 2 Write a Korn shell script filecount which counts the number of ordinary files (defined as everything except the following), number of executable files, number of links, and number of directories in one or more directories which are provided as commandline arguments. Requirements ? The above counts include dot files, except that . and .. are not included in the directory count (investigate the -A option to ls). ? Files in sub-directories are not included in the counts. ? The distinction between file types is the same as that of ls -F. ? If the script is invoked with no directory name provided, it must work on the current directory. Otherwise, it must produce a single line of output for each directory it processes, as in the following
  • 10. sample (on fictitious locations): 1 $ ./filecount 2 . : 10 ordinary 9 executable 3 links 5 directories 3 $ 4 $ ./filecount courses tmp 5 courses: 2 ordinary 8 executable 7 links 42 directories 6 tmp : 8 ordinary 17 executable 5 links 51 directories ? The script must support the following command-line options: -f: include the count of ordinary files in the output -x: include the count of executable files in the output -l: include the count of links in the output -d: include the count of directories in the output If any of these options are specified when the script is called, then only the requested totals must be printed for each directory.
  • 11. ? If an invalid option <option> is given, the script must print ./filecount: Illegal option: <option> and a usage message to stderr and halt with a exit status 1 as shown below. 1 $ ./filecount ?t 2 ./filecount: Illegal option ?t 3 Usage : filecount [?dflx] [directory . . . ] 4 $ echo $? 5 1 ? If an invalid directory <directory> is given, the script must print ./filecount: Invalid directory: <directory> and a usage message to stderr and halt with a exit status 2. 1 $ ./filecount somedir 2 ./filecount: Invalid directory: somedir 3 Usage : filecount [?dflx] [directory . . . ] 4 $ echo $? 5 2
  • 12. ? The script must execute using the Korn shell interpreter (ksh). You may not use C, C++, Perl, Python, Ruby, or any similar language. ? The script must run at the command line as: ./filecount [-dflx] [directory ...]. ? The script must have -rwxr-x-- permission. ? The script must terminate with a proper exit statement. ? Do not use any specific aspects of your environment within the script. In other words, use native Linux command names as opposed to your environment¡¯s aliases for those commands and do not rely on any specific aspect of your environment (e.g., values of particular shell variables). ? Each line of output must separate the directory from the counts with a single colon (:) followed by exactly two spaces. Delimit each count
  • 13. from its label with a single space and delimit each count label pair from each other with exactly two spaces (exactly as shown above). Always print the ordinary count first, followed by the executable count, then the link count, and finally the directory count, if requested, regardless of the order in which the options are given on the command line. ? Each line of output must not contain any leading and trailing whitespace or any extraneous text. ? All options must precede all directories on a command line. ? Use - to indicate the end of options. ? Options can be given as singletons (e.g., -x) or in any combinations (e.g., -fx, -xf, -fxld). ? The file counts are mutually-exclusive. One file must never be counted twice. Anything that is not a directory, symbolic link, or executable, is an ordinary file.
  • 14. ? Executable files are to be counted as executable only, not executable and ordinary. ? The script must not create any new files or remove any existing files. ? The script must not create any new directories or remove any existing directories. You are encouraged to make creative use of the given tools (grep, sed, awk, and others) and string operators (i.e., do not reinvent the wheel). Remember, grep, sed, and awk can be used on shell variables (e.g., $(echo $PATH | sed ¡¯s/:/2/g¡¯)). Also, explore getopts (though not necessary), ls -A, print -n, and print - -n. If designed properly, the script required for this homework should occupy no more than 100 lines of code.