Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

pipes and regular expressions pipes and filters the module is operating systems these are word listing commands https://users.cs.duke.edu/~ola/ap/linuxwords The first word in the file. Can

pipes and regular expressions
pipes and filters
image text in transcribed
image text in transcribed
the module is operating systems
these are word listing commands https://users.cs.duke.edu/~ola/ap/linuxwords
The first word in the file. Can you guess what it will be, it is a city in Europe? The last word in the file. Can you guess this one, another city in Europe? The number of words in the words file - there is one word per line. The 6171st word in the file. Can you read my mind and guess this word directly? 23:56 X Lab3 Q Lab3-pipes the command is head runs is and head and pipes the standard output of ts into the standard input of head The following shell commands are particularly useful in pipes cat (FILENAME (FILENAME. I writes the contents of one or more files to standard output. This is a good way of starting a pipe. If you leave off all the filenames, cat just reads its standard input and write it to standard output head In Nreads as standard input and writes only the first lines (default a 10 if you leave the option off) to standard output. You can also put a minus before the argumenteg head-A-2 to skip the last 2 lines and write all the rest tal-N is like head except that it writes the last N lines with a minust skips the first ones! sort reads all its standard input into a memory buffer, then sorts the lines and writes them all to standard output uniq reads standard input and write to standard output, but skips repeated lines that immediately follow each other, for example if there are three lines A A B then it would only write A B but if it gets A, B, A it would write all three. A common way to remove duplicate lines is sor unig 1 grep I-EXPRESSION reads standard input and prints only lines that match the regular expression to standard output. With it is case-insensitive, and with it only prints lines that do not match the expression sed - COMMAND reads lines from standard input, transforms them according to the co nd and writes the results to standard output. sed has its own command language but the most common one is S/SOURCE/DEST/ which changes substrings matching the source regular expression into the destination one we stands for word count, but with 4 it counts lines instead. Putting a welon the very end of a pipe is useful if you just want to know how many results a particular command or pipe produces, assuming the results come one per line All these commands actually take an optional extra filename as argument, in which case they read from this file as input. For example, to display the first 10 lines of a file called Readme.txt, you could do either cat Readme.txt head or head Readme.it Word list exercises-pipes and regular expressions

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

Step: 3

blur-text-image

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