In Linux, write a bash script named dlist that takes one argument, either a d, o
ID: 3682567 • Letter: I
Question
In Linux, write a bash script named dlist that takes one argument, either a d, or an x, or an nx. If no argument or more than one argument is given, then print an error message, such as "incorrect number of arguments". If the argument is 'd', then dlist lists all of the directories within the current directory. If the argument is 'x' then dlist lists all of the ordinary, executable file (not directory). If the argument is 'nx' then dlist lists all of the ordinary, non-executable files in the current directory.
Explanation / Answer
#!/bin/bash
echo enter input who,cal,ls,ps,pwd,bash
read inpt
case "$inpt" in #using case to execute statements
who) who
;;
cal) cal
;;
ls) ls
;;
ps) ps
;;
pwd) pwd
;;
bash) bash
;;
*) echo "Invalid"
;;
esac
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.