Make a directory named hw4 then cd into that directory • In the hw4 directory use nano to create a text file named words.txt that contains 6 words – each on a different line. They can be any random words. For example: eggs apples class homework car games
part two:
Write a shell script named hw4.sh that first clears the screen (using the clear command) then does the following:
• Asks the user (using the echo command) to enter a file name.
• Reads the file name (entered by the user) and stores it in a variable.
• cat the file (that was entered by the user)
• Display the contents of the file sorted (use the linux sort command)
• Display a count of the number of lines in the file (using the wc –l command, note that the letter after the dash is the lower case L)
• After each of the above steps print a string of dashes (“----------”) on a new line to separate the output. You can use the echo command for this.
linux
part 1
**********
mkdir hw4
cd hw4
nano words.txt
eggs apples class homework car games
Part 2
*************
#!/bin/bash
clear
echo "Enter Filename: "
echo "==================="
read fn
cat $fn
echo "==================="
echo "After sorting"
echo "================"
cat $fn | sort
echo "================"
cat $fn | wc -l
echo "================"
if you have any doubt then please ask me without any hesitation in the comment section below, if you like my answer then please thumbs up for the answer, before giving thumbs down please discuss the question it may possible that we may understand the question in a different way and I can edit and change the answers if you argue, thanks :)
Get Answers For Free
Most questions answered within 1 hours.