Modify your script for #17 to change the background and font colors of your logi
ID: 3721146 • Letter: M
Question
Modify your script for #17 to change the background and font colors of your login session as defined in your .profile or .bashrc
Write a Bash script called make_animal.sh in a directory called zoo. Use the following specifications: • Creates a file animal with the following data: Aardvark Bat Camel Donkey Elephant Fox Giraffe • Translate all of the “a” characters to “v” characters into another file called animal2. • Sort and display the output from the animal2 file. • Append the date to the end of the animal2 file. • Display “echo” a line that says “These are a number of basic animals that exist throughout the world. These different animals exist in different areas depending on the terrain and the climate.” • Change the file to read execute permissions for everybody. (Keep write permissions for yourself.)
Explanation / Answer
#!/bin/sh
#read a file animal containing text Aardvark Bat Camel Donkey Elephant Fox Giraffe, each word in a line
before=`cat animal`
echo "$before"
#replace a with v
after=${before//a/v}
echo $after >> animal2
# sort and print animal2
sort animal2
# add date in the end of the filename
now=`date +"%m_%d_%Y"`
mv animal2 animal2_$now
#printing desired test
echo "These are a number of basic animals that exist throughout the world. These different animals exist in different areas depending on the terrain and the climate."
#change the permission of file to read(4) and execute(1)
chmod 555 animal2_$now
OutPut:
animal :
Aardvark
Bat
Camel
Donkey
Elephant
Fox
Giraffe
animal2:
Avrdvvrk
Bvt
Cvmel
Donkey
Elephvnt
Fox
Girvffe
Note:[Please revert back with comment in case of any query. Happy to help]
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.