Question: Bash. This week you will create two bash scripts: Create a bash script named backup.sh. This script should create a tar file containing all .c
Bash. This week you will create two bash scripts:
Create a bash script named backup.sh. This script should create a tar file containing all .c files in the current directory, gzip that tar file, copy the resulting file to the users home directory, and report that the file was created. The date of the create gzip file should include the current date and time.
The output of your program should look like this:
$ ls
backup.sh goodbye.c hello.c
$ ./backup.sh
all .c files copied to ~/backup2016-09-21_09-29.tar.gz
$ ls ~/back*
/home/CLASSES/brunsglenn/backup2016-09-21_09-29.tar.gz
$
The file name format should be exactly as shown, with first the year, month, and day, separated by hyphens, then an underscore, then the hour and minute, separated by a hyphen.
Create a bash script named most_proc.sh. This script should show the top 10 users according to the number of processes they are running. It should show the process count and the user name.
The output of the script should look something like this, depending on which users are active.
$ ./most_proc.sh
157 root
12 apache
11 brun1992
4 bb
2 postfix
2 hart4492
2 68
1 USER
1 sshd
1 rpcuser
I dont care about the order of users with the same number of processes.
Some hints: 1) you will probably want to use ps with certain options to see all processes of all users. 2) if you use awk {print $2} you will get the second column of text. 3) dont forget some of the text processing commands we covered in lecture this week.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
