Hello, I am attempting to write a basic shell script using bash. It will need to print the user, host, time, and date. It will need to take user input for a txt file to be searched and create a new file to save the results. It must print the number of lines and characters in the text. The user will need to enter three words to be searched, and the number of occurrences of those words in the text will be reported. Then, a comparison will be made displaying the words in order from greatest to least.
I am running putty on windows and using the pico editor. If anyone could help me get started I would greatly appreciate it. Thank you.
#!/bin/bash
echo "Username: " `whoami`
echo "Host: " `hostname`
echo "Date & Time: " `date`
echo
echo "Enter file name to search "
read fn
echo
echo "Number of lines in file $fn are : " `wc -l $fn`
echo "Number of characters in file $fn are: " `wc -c $fn`
echo
echo "Enter three word to search in file $fn 1 : "
read sr1
echo
echo "Enter three word to search in file $fn 2 : "
read sr2
echo
echo "Enter three word to search in file $fn 3 : "
read sr3
result1=`grep $sr1 $fn -o | wc -l`
result2=`grep $sr2 $fn -o | wc -l`
result3=`grep $sr3 $fn -o | wc -l`
echo
echo "result 1 of word $sr1 : " $result1 > result.txt
echo "result 2 of word $sr2 : " $result2 >> result.txt
echo "result 3 of word $sr3 : " $result3 >> result.txt
cat result.txt | sort -r
rm -rf result.txt
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
different way and we can edit and change the answers if you argue,
thanks :)
Hello, I am attempting to write a basic shell script using bash. It will need to...
Write a script using the bash shell to add new users to the system. The script should read user information from a comma-delimited file (each field should be separated by a comma). The filename should be passed to the script as a command-line argument. Be sure the script contains a usage clause. The input file should contain the user information with one user per line. As the system administrator, you should determine the information necessary for each user to properly...
Hello I need help creating a bash script in linux for the following question: Create a script to expand the jpeg creator to create other types of files such as pdf, png, gif, etc. The jpeg creator is the following: #!/bin/bash FILE=$1 echo -e -n "\xFF\xD8\xFF\xE0"> $FILE dd if=/dev/random bs=512 count=4 >> $FILE
I need help with this. 1. In a bash shell script, what are the required elements of an "if" control structure? 2. In a bash shell script, what are the optional elements of an "if" control structure? 3. In a bash shell script, what are the required elements of a "while" control structure? 4. What is the difference between a shell variable and environment variable? Which one is considered local and which is considered global? 5. List the four kinds...
I need a bash script that prompts the user for a filename within a directory, and if the file/subdirectory exists to gzip them. Directories should be tarred and zipped, files should just be gzipped. This should poll inside of a loop to keep prompting the user until the user ends the script.
Hello all, I have a c++/unix (bash) question. I am struggling on starting this assignment. If you could start the assignment and tell me how to do the rest it would be greatly appreciated! (Quick thumbs up answer response if thorough and correct) Maintain automobile records in a database Write a shell script to create, view and modify a simple database that contains automobile records. The shell script has to be done in Bourne shell syntax (bash as a matter...
Hello, I need help creating a bash script for the following question, please also show screen shot of running the program, thank you for your help in advance Create a script to create files such as jpeg, pdf, png, gif, etc.
Hello I need help creating a bash script for linux as shown below getting the information from ifconfig The script must programmatically gather and output the informationEXACTLY AS SHOWN BELOW and (not echo this and echo that). ====================================== Interface: AAA MAC Address: BB:BB:BB:BB:BB:BB IP Address: CCC.CCC.CCC.CCC Subnet Mask: DDD.DDD.DDD.DDD Received Bytes: EEEEEE ====================================== Thanks,
Hello, I would greatly appreciate it if anyone could help me. I saved a text file in the C drive of my computer. I need to use open the text file to do my homework. But when I used the Python 3.7 to open the file, I got error message: NO SUCH FILE OR DIRECTORY. What should I do to open the file using the Python. Many thanks for your help.
I am having trouble on what exactly to write so I can make the script work, can someone show how to properly do it? Use the vi editor to enter the following script (name this file testscript): #!/bin/bash #script to demonstrate : reading arguments from a command line & # interactively from within script # selection (if… then… else…. fi) # iteration (for loop) # USE FILES ENTERED ON THE COMMAND LINE echo The script you are running is $0...
8. (4 pts + 2Xc) Write a bash shell script called 08-numMajors that will do the following i. Read data from a class enrollment file that will be specified on the command line ii. If the file does not exist, is a directory, or there are more or less than one parameters provided, display an appropriate error/usage message and exit gracefully Display the number of a specified major who are taking a given class iii. The following is a sample...