Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

og files, and other text - based data in a Linux environment. Please provide a screenshot as proof of work for every instruction executed. Log

og files, and
other text
-
based data in a Linux environment.
Please provide a screenshot as proof of work for every instruction executed.
Log in to Ubuntu
instructions:
1
.
Create a text file:
Create a text file
(
e
.
g
.
,
sample.txt
)
using a text editor or command line tools such as touch and
echo. Add some random text to this file.
You can use the text editor and save the file with the
.
txt extension.
(
Note: Please choose a sample text such that the below commands can be effectively executed
)
2
.
View the file contents:
Use the cat command to view the contents of the text file you created.
3
.
Review of the text:
Use the grep command to search for a specific word or phrase in a text file. For example, look
for occurrences of the word "Linux."
grep
-
i
text
_
to
_
search
sample.txt
4
.
Read the alphabet:
Use the wc command to count the number of words and characters in a text file.
5
.
Complete the text:
Use the sort command to sort the text in a file alphabetically.
6
.
Create a new file with the following text:
Use the
>
or
>
>
operator to redirect the sorted output to another file
(
e
.
g
.
,
sorted
_
sample.txt
)
.
7
.
Replace text:
Use the sed command to replace a specific word or phrase in the root text file
(
e
.
g
.
,
"Ubuntu"
instead of "Linux"
)
.
8
.
Add text to the original file:
Use the
>
>
operator to add additional information to the original file
(
e
.
g
.
,
add a few lines
)
.
9
.
Extract specific Lines:
Use the head and tail commands to remove the first and last lines of the text file.
1
0
.
Remove specific Lines:
Use the sed or grep
-
v command to extract specific lines containing a specific word from a text
file.
PART B
NOTE:
1
.
YOU FIRST HAVE TO CREATE FILES IN A DIRECTORY AND SHOW
SCREENSHOT OF CREATED FILE NAMES
(
YOU CAN CREATE FEW DUMMY.TXT FILES
)
2
.
PRODUCE A SCREENSHOT WHEN YOU ARE RUNNING THE SCRIPT IN THE
TERMINAL
3
.
PRODUCE A SCREENSHOT CONSISTING OF RENAMED FILES
Goal: Write a simple shell script to automate a common task.
Steps:
1
.
Create a Shell Script:
Create a text file with a
.
sh extension. You can use a text editor of your choice. For example,
you can use the nano text editor to create a new script file named rename
_
files.sh:
bash
Copy code
nano rename
_
files.sh
2
.
Write the Script:
Inside the rename
_
files.sh script, you can write a script that renames all
.
txt files in a directory
by adding a prefix to their filenames.
3
.
Make the Script Executable:
Before you can run the script, you need to make it executable. You can do this with the chmod
command:
bash
Copy code
chmod
+
x rename
_
files.sh
4
.
Run the Script:
You can now run the script by providing a prefix as an argument. Remember to replace new
_
with the prefix you want to use.
This assignment not only automates a visible task but also helps you learn the basics of
scripting, conditional statements, and loops in Bash

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Evaluate the importance of the employee handbook.

Answered: 1 week ago

Question

Discuss the steps in the progressive discipline approach.

Answered: 1 week ago