0% found this document useful (0 votes)
78 views1 page

Lice 22

The command redirects input from file1 to the command, redirects standard output to file2, and redirects standard error to file3. Executing a command with exec replaces the current process rather than creating a new child process, so the shell will terminate when the command finishes. To emulate wc -l and count lines using awk, use the END block and print the NR variable which contains the number of input records/lines processed. To count lines containing a specific word in a file, use grep -c and the search word as the argument. egrep supports additional regex features like quantifiers and alternation that standard grep does not.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
78 views1 page

Lice 22

The command redirects input from file1 to the command, redirects standard output to file2, and redirects standard error to file3. Executing a command with exec replaces the current process rather than creating a new child process, so the shell will terminate when the command finishes. To emulate wc -l and count lines using awk, use the END block and print the NR variable which contains the number of input records/lines processed. To count lines containing a specific word in a file, use grep -c and the search word as the argument. egrep supports additional regex features like quantifiers and alternation that standard grep does not.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

27: I want to read all input to the command from file1 direct all output to file2 and error to

file 3, how can I achieve this?

command <file1 1>file2 2>file3

28: What will happen to my current process when I execute a command using exec?

“exec” overlays the newly forked process on the current process ; so when I execute the
command using exec, the command gets executed on the current shell without creating any new
processes.

Eg: Executing “exec ls” on command prompt will execute ls and once ls exits, the process will
shut down

29: How will you emulate wc –l using awk?

awk ‘END {print NR} fileName’

30: Given a file find the count of lines containing word “ABC”.

grep –c “ABC” file1

31: What is the difference between grep and egrep?

egrep is Extended grep that supports added grep features like “+” (1 or more occurrence of
previous character),”?”(0 or 1 occurrence of previous character) and “|” (alternate matching)

You might also like