Question

In: Computer Science

Use Vi text editor or ATOM to create a bash script file. Use the file name...

Use Vi text editor or ATOM to create a bash script file. Use the file name ayaan.sh. The script when ran it will execute the following commands all at once as script. Test your script file make sure it works.

Here is the list of actions the script will do:

  1. It will create the following directory structure data2/new2/mondaynews off your home directory.
  2. inside the mondaynews, create 4 files sports.txt, baseball.txt, file1.txt and file2.txt. Make sure file1.txt and file2.txt are hidden files.
  3. Next use the ls command to display all 4 files in the mondaynews directory including the hidden files
  4. The next action redirect the result of the command you ran in #3 to a new file called show4files.txt
  5. Return the user to his/her home directory.

Thank you in advance. Please show screenshots so I can learn what you did. I'm stuck

Solutions

Expert Solution

BASH Script:

#!/bin/bash

# Go to home directory first
cd ~
# Create directory structure data2/new2/mondaynews in the home directory
mkdir data2
mkdir data2/new2
mkdir data2/new2/mondaynews

# Go to mondaynews folder
cd data2/new2/mondaynews

# Create four files sports.txt, baseball.txt, file1.txt and file2.txt
# Here file1 and file2 are hidden by using dot (.) before their names
touch sports.txt baseball.txt .file1.txt .file2.txt

# Display all files (hidden and not hidden) using ls command
ls -a

# Redirect output of ls command to a new file called show4files.txt
ls -a > show4files.txt

# Return to home directory
cd ~

BASH SCRIPT SCREENSHOT:

TERMINAL OUTPUT:

FOR ANY HELP JUST DROP A COMMENT


Related Solutions

Word Frequencies (Concordance)    1. Use a text editor to create a text file (ex: myPaper.txt)...
Word Frequencies (Concordance)    1. Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. 2. Write a Python program (HW19.py) that asks the user to provide the name of the text file. Be SURE to check that it exists! Do NOT hard-code the name of the file! Use the entry provided by the user! read from the text file NOTE: (write your program so that...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
Python: Word Frequencies (Concordance) 1. Use a text editor to create a text file (ex: myPaper.txt)...
Python: Word Frequencies (Concordance) 1. Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. 2. Write a Python program (HW19.py) that asks the user to provide the name of the text file. Be SURE to check that it exists! Do NOT hard-code the name of the file! Use the entry provided by the user! read from the text file NOTE: (write your program so that...
The vi text editor can be a bit challenging to use at first, but once you...
The vi text editor can be a bit challenging to use at first, but once you have familiarized yourself with how it works you will find it an efficient way to create and edit text files in Linux, and UNIX as well. The key thing to remember is that vi has two operational modes: insert mode and command mode. In insert mode, everything you type is entered into your file. You can use the backspace, delete and the arrow keys....
Write a bash shell script that takes exactly one argument, a file name. If the number...
Write a bash shell script that takes exactly one argument, a file name. If the number of arguments is more or less than one, print a usage message. If the argument is not a file name, print another message. For the given file, print on the screen its content.
Bash script: Create a bash script that takes numbers as parameters, calculates sum and prints the...
Bash script: Create a bash script that takes numbers as parameters, calculates sum and prints the result. If no parameters passed, prompt a user (only one time) to enter numbers to sum and print the result. Submit your program as LastName_FirstName.sh file.
a) Using vi (or from your favorite editor) create a file called myscript. Enter the following...
a) Using vi (or from your favorite editor) create a file called myscript. Enter the following text into the myscript file. #!/bin/bash echo -e "this is a sample shell script. \t It displays mounted filesystems \a" mount b) Now, save the file and quit the editor. c) type ls -l myscript and hit enter. What permissions do you have on the file? d) type bash myscript and hit enter. What did it do? e) what does the \t and \a...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name...
PLEASE USE LINUX/UNIX 1.Use either pico, vi, or cat to create the following file and name it as “mysedfile”: Name Class1 Class2 Class3 Tom 92 94 88 Nancy 91 85 95 Lisa 99 77 96 Jerry 84 98 90 2. Please use sed command(s) to complete the following tasks. display Tom’s record. display Lisa’s record. display both Tom’s and Lisa’s records. remove the blank line(s) from “mysedfile.” replace all the digits with *.
Python File program 5: Word Frequencies (Concordance)    20 pts 1. Use a text editor to create...
Python File program 5: Word Frequencies (Concordance)    20 pts 1. Use a text editor to create a text file (ex: myPaper.txt) It should contain at least 2 paragraphs with around 200 or more words. 2. Write a Python program (HW19.py) that asks the user to provide the name of the text file. Be SURE to check that it exists! Do NOT hard-code the name of the file! Use the entry provided by the user! read from the text file NOTE:...
Program in Bash: Write a program using bash script that can read a file from the...
Program in Bash: Write a program using bash script that can read a file from the same directory, sort the nonrepeating integers from 0-9 from smallest to largest, and output the results on the same line. Do not use the sort function.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT