Can some one please help me, thanks. During the initial setup and implementation
ID: 3639874 • Letter: C
Question
Can some one please help me, thanks.During the initial setup and implementation of the Web site, you have been reviewing some of the documentation, scripts, and sample files that were installed on the Linux and Apache environment. In more than one place you have noticed several familiar commands, but they have all been on one line. The ability of one command to send the output it generates to the input of a second command is a very important concept for the UNIX environment.
Describe the concepts of filters, pipes, and redirection and explain how and what the following commands are trying to accomplish (if some commands are not yet familiar, you can describe the overall process of each step):
ls /etc | grep conf | grep -v "." | sort > ~/conf
cat /etc/passwd | awk -F":" '{print $1}' | sort >> ~/users 2>&1
The deliverable for the assignment should include:
Explanation / Answer
Filters: Small programs or commands that manipulates text or data from "standard input" and writes its results to "standard output". The three most popular "filters" are "sed", "awk", and "grep".
Pipes: A symbol that means "take the output of the previous command and send it to the following command". This can be useful for sending information to filters or other programs.
Redirection: This is a symbol that tells the console to redirect all output (with error or not) to a file. This can be useful for logging and saving specific data.
Explanation of commands:
"ls /etc | grep conf | grep -v "." | sort > ~/conf":
This command first lists (ls) the contents of the "/etc" directory, sends that output (pipe) to the filter "grep", which only shows the lines that contain the word "conf" in it. That output is then pipped to the "grep" filter again, which then searchs for only the lines that do NOT contain "." (the -v inverses the filter). Finally, the data (which now is the contents of "/etc" directory that contains "conf" but doesn't contain ".") is then sorted and redirected to the file "conf" located in the home folder of the user. So, if your username was "user", the file "/home/user/conf" would now contain lines of text corresponding to a list of files in the "/etc/" directory that contains the string "conf" but not the string ".", and sorted.
"cat /etc/passwd | awk -F":" '{print $1}' | sort >> ~/users 2>&1"
This command reads the file "/etc/passwd" (cat), pipes all the data read to the filter "awk", which "splits" on a ":" (the -F does that), and prints the FIRST part of the result ("{print $1}"), and then sorts it. This would result in getting all the "users" of a system (including system/program users). All this data is then stored in the file "~/users", which, again, if your username was "user", would be located at "/home/user/users". Lastly, the "2>&1" means that ERROR output ("standard error") is redirected to STANDARD output, so any errors will display to the console.
I hope this helped.