Time Sensitive Shell Scripting File1 can hold any content b
(Time Sensitive)
Shell Scripting [ File1 can hold any content, but cannot have an extension eg .txt]
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.
Solution
Assume the content in file1 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
2. Select lines from file file1 that have at least 3 characters
awk \'{if(length($0) >= 3) print}\' file1
3. Select lines from file file1 that have 3 or less characters
awk \'{if(length($0) <= 3) print}\' file1
4. select non-blank lines from the file file1
awk \'{if(length($0) > 0) print}\' file1
5. Select lines from file file1 starts with capital letter
grep -o \"^[A-Z]\\w*\" file1
6. Select lines from file file1 ends with a period
grep -o \"\\w*[\\.\\!\\?]$\" file1
7. Select the lines from file file1 that have the string unix
grep -o \"\\w*unix\\w*\" file1
8. Select the lines from file file1 that end with the string unix.
grep -o \"\\w*unix$\" file1
9. Select the lines from file file1 that have only the string unix.
grep -o \"^unix$\" file1
10. Select the lines from file file1 that have the pattern unix at least two times.
grep -o \"\\w*unix\\w*unix\\w*\" file1
11. Select the lines from file file1 that have the pattern unix and ends with unix.
grep -o \"\\w*unix\\w*unix$\" file1
12. Copy file file1 on the screen, but delete the blank lines.
awk \'{if(length($0) > 0) print}\' file1 | cat
13. Select the lines from file file1 that have a digit.
grep -o \"\\w*\\d\\w*\" file1
14. Select the lines from file file1 that have at least two digits without any other characters in between
grep -o \"\\w*\\d\\d\\w*\" file1
![(Time Sensitive) Shell Scripting [ File1 can hold any content, but cannot have an extension eg .txt] Select the lines from file file1 that have exactly three ch (Time Sensitive) Shell Scripting [ File1 can hold any content, but cannot have an extension eg .txt] Select the lines from file file1 that have exactly three ch](/WebImages/45/time-sensitive-shell-scripting-file1-can-hold-any-content-b-1142102-1761612810-0.webp)
![(Time Sensitive) Shell Scripting [ File1 can hold any content, but cannot have an extension eg .txt] Select the lines from file file1 that have exactly three ch (Time Sensitive) Shell Scripting [ File1 can hold any content, but cannot have an extension eg .txt] Select the lines from file file1 that have exactly three ch](/WebImages/45/time-sensitive-shell-scripting-file1-can-hold-any-content-b-1142102-1761612810-1.webp)