Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create shell scripts to do the following. 1. 2. Script1.sh - run the ps command and grep for a string. The string should be the
Create shell scripts to do the following. 1. 2. Script1.sh - run the ps command and grep for a string. The string should be the first argument to the script - if the command has more than 3 lines - send the output to a file given by the second argument to the script . Make sure the command has 2 arguments . if not, print a prompt asking for 2 arguments and explain them Script2.sh check if directory exits (argument 1 to the script) if not make the directory . if it does make 10 subdirectories prefix will be argument 2 to the script prefix-directorynumber will be the format for the subdirectories copy argument 3 into each subdirectory Script 1 unix: /home/millermj/435/Labi ./Scripti.sh miller Please give z arguments. 1) text to grep for 2) file to send output to unix: /home/millermj/435/Labi ./Scripti.sh miller ps.txt Running grep on miller Grep found 19 lines, sending to file ps.txt unix: /home/millermj/435/Labi ./Scripti.sh xyz ps.txt Running grep on xyz Grep found 3 lines, NOT sending to file unix: /home/millermj/435/Labi Script 2 unix: /home/millermj/435/Labi ./Script2.sh hello yo cat.txt unix: /home/millermj/435/Labi ./Script2.sh hello yo cat.txt unix: /home/millermj/435/Labi cd hello unix: /home/millermj/435/Labi/hello find ./ ./yo-1 /yo-1/cat.txt ./yo-2 /yo-2/cat.txt - /yo-3 ./yo-3/cat.txt ./yo-4 ./yo-4/cat.txt ./yo-5 ./yo-5/cat.txt ./yo-6 ./yo-6/cat.txt /yo-7 ./yo-7/cat.txt /yo-8 ./yo-8/cat.txt ./yo-9 - /yo-9/cat.txt /yo-10 ./yo-10/cat.txt unix: /home/millermj/435/Labi/hello cat ./yo-2/cat.txt hello Resources https://devhints.io/bash Hints Run a command and send output to variable VAR='ls -hal Get the value of a var with newlines echo "$VAR" What to turn in: submit all scripts to the dropbox on canvas
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started