Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Time sensative (linux). Please 1)Show all lines that have only the word hello in

ID: 3782516 • Letter: T

Question

Time sensative (linux). Please

1)Show all lines that have only the word hello in file file1.

2)Show all lines that have at least five characters.

3)Show all lines that have only 5 digits.

4)Write the command to find out the number of words in the file file1.

5)Write the command to substitute all the words Unix to Linux in a file called file1.

6)Write the command to rename the file file1 to file2.

7)Write the command to list only the directories in the current folder.

8)Use the sed command to print lines 6 to 10. Modify that command to place lines 6 to 10 of file1 into file2.

9)A file has three columns. In column-1 the name of employee and in column-2 he salary of employee is given.

10)Write the line to display the name of employees that make more than 50000.

11)Write a script to read three numbers and find the sum of these numbers. Find the largest number. Display the largest number and the sum.

Explanation / Answer

1) grep -i hello file1.txt

Grep command is used to search for the pattern and -i is the option it iteratively searches the file for the pattern and it displays it encounters the word.

2) grep -r '.{5}' file1.txt

To grep command recursively search for the whole file with characters length having 5.

3)egrep '[0-9][0-9][0-9][0-9][0-9]' file1.txt

Or

grep -E '[0-9]{5}' file1.txtlll

This extended grep command will search for the 5 digit numbers in the file.

4) wc -w file1.txt

The wc command searches for the words in the given file and gives us the count.

5) sed -ie 's/Unix/Linux/g' file1.txt

Stream editor is the command to find and replace the pattern. In this s tells that substitute the Unix with Linux and g means globally among the file.

6) mv file1.txt file2.txt

Mv is the only command used to rename the files.

7) ls -d

Ls is the list command , -d means the directory it lists all the directory in the current folder.

8)sed -n 6:10p file1.txt>patch

sed -i patch file2

The first line will copy the lines 6 to 10 to the temporary file patch and the 2 command will insert the patch file to file2.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote