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

THESE QUESTIONS ARE FOR UNIX (LINUX) Select the lines from file file1 that have

ID: 3781318 • Letter: T

Question

THESE QUESTIONS ARE FOR UNIX (LINUX)

Select the lines from file file1 that have exactly three characters in them. Select the lines from file file1 that have at least three characters in them. Select the lines from file file1 that have three or less characters in them Select the non-blank lines from the file file1. Select the lines from file file1 that start with a capital letter. Select the lines from file file1 that end with a period. Select the lines from file file1 that have the string unix. Select the lines from file file1 that end with the string unix. Select the lines from file file1 that have only the string unix. Select the lines from file file1 that have the pattern unix at least two times. Select the lines from file file1 that have the pattern unix and ends with unix. Copy file file1 on the screen, but delete the blank lines. Select the lines from file file1 that have a digit. Select the lines from file file1 that have at least two digits without any other characters in between.

Explanation / Answer

Assume the content in file1.txt is as mentioned below:

Asdfasfgsdf
sfdvfbdfhdh
as
Cv
ssdk.
dgsefg
Jsdsdfsfb

Defbsgb
sfndfhndfhb
afvafbaeg!
Jsdsdfsf

ggg
wer

1. Select lines from file file1 that have exactly 3 characters

awk '{if(length($0) == 3) print}' file1.txt

2. Select lines from file file1 that have at least 3 characters

awk '{if(length($0) >= 3) print}' file1.txt

3. Select lines from file file1 that have 3 or less characters

awk '{if(length($0) <= 3) print}' file1.txt

4. select non-blank lines from the file file1

awk '{if(length($0) > 0) print}' file1.txt

5. Select lines from file file1 starts with capital letter

grep -o "^[A-Z]w*" file.out

6. Select lines from file file1 ends with a period

grep -o "w*[.!?]$" file.out