Question

In: Computer Science

1. Show how to redirect the standard output of the date command to a file named...

1. Show how to redirect the standard output of the date command to a file named currentdate.

2. Continuing from the previous question: Show how to append the standard output of the who command to the file currentdate.

3. The password file (/etc/passwd) contains one line for each userid registered with the system. Show how to display the number of userids in the passwd file on the screen.

4. Employ a pipe to combine the who and the wc commands to show the number of userids currently logged into the system.

5. Write a Unix command line to list only the 20th last file in the directory /etc.

6. Write a Unix command line to to count how many files and directories you have the execute permission for in your home directory.

7. In the following pipeline, the find command searches all the directories under /etc looking for files owned by userid root. The names of all such files are then written to standard output, one per line. The output of find is piped to wc -1 to count the lines:

find /etc -type f -user root -print | wc -l

As find does its work, it will generate various error messages you don’t want to see. Your goal is to rewrite the pipeline to throw away the error messages without affecting the rest of the output. Show how to do this for BASH shell.

Solutions

Expert Solution

Answer 1
**************

date > currentdate

Answer 2
**************

Answer 3
***************

Answer 4
*************

Answer 5
**************

Answer 6
************

Answer 7
**************

find /etc -type f -user root -print -name expect 2>/dev/null | wc -l

Thanks


Related Solutions

Write a program that creates an output file named rand_nums.txt. Open the file and write 100...
Write a program that creates an output file named rand_nums.txt. Open the file and write 100 random integers between -50 and +50 (inclusive) to the file. Be sure to handle any file IO exceptions. Remember to close the file. Write a program that opens rand_nums.txt for input. Create two output files pos.txt and neg.txt. Read through the input file, one line at a time, converting each line into an integer (no exception handling, yet). If the number is positive, write...
1. At the command prompt, use the where command to locate the where.exe file. Copy and...
1. At the command prompt, use the where command to locate the where.exe file. Copy and paste the full path and filename for the where.exe file into the space provided below. 2. At the command prompt, enter the following command and press enter. find "free beer" "c:\Program Files (x86)\Notepad++\*.txt" This command searches for the string "free beer" in all .TXT files in the Notepad++ program folder. According to the output of the find command, which of the files listed below...
•Modify p4.c so that the output file p4.output is created but also displayed to standard output...
•Modify p4.c so that the output file p4.output is created but also displayed to standard output ( the screen ). This should be done by another instance of exec(). •Implement the pipe() command to do the following: $> grep –o else p4.c | wc –l p4.c #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <fcntl.h> #include <sys/wait.h> int main(int argc, char *argv[]) { int rc = fork(); if (rc < 0) {     // fork failed     fprintf(stderr, "fork...
For CB output, you should paste the forecast output in your Excel calculations file. Show the...
For CB output, you should paste the forecast output in your Excel calculations file. Show the split view in all CB output. 1.   Two investments (A and B, below) have been proposed to the Capital Investment committee of your organization; a.      The required rate of return for your company is 15%. What is the NPV for each investment? Assume the initial investments ($150k and $50k) occur at the beginning of the year and all other costs and benefits occur at...
A network administrator views the output from the “show ip route” command. What kinds of things...
A network administrator views the output from the “show ip route” command. What kinds of things do you think the administrator will see on the output? Based on your work this week, what do you think you can learn from such commands? Give an example of how you would improve your network using output from “show ip route”
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on...
Create a bash script file named assessment-script-a that: 1. Accepts any number of file names on the command line 2. For each file name provided, delete any line that contains the string: qwe.rty When the changes are completed, the script should display the total number of files scanned, and the total number of files changed. Example Command: assessment-script-a file.a file.b file.c file.d file.e    Example Output: 5 files scanned, 3 files changed 3. Your script should include a series of...
How this command used for and provide examples for each one. Commands: 1-file 2-find 3-pwd 4-ln...
How this command used for and provide examples for each one. Commands: 1-file 2-find 3-pwd 4-ln 5-stat 6- cmp, comm, and diff 7-md5sum 8-du 9-gzip 10-gunzip 11-bzip2, and bunzip 12-cpio 13-tar 14-wc 15-vi editor
Part 1: netstat Run the 'netstat' command and review the output. Note that the first part...
Part 1: netstat Run the 'netstat' command and review the output. Note that the first part of the output is a list of active Internet connections, and the second part is a list of active sockets. The format of each part is different (i.e. different number of columns per line, and different column headers). 1. Write a bash command line that will display the number of active Internet connections as reported by 'netstat'. Your output should be a single number....
1. Using the alter table command, add a new column named gender making sure that only...
1. Using the alter table command, add a new column named gender making sure that only values of M, F or O are allowed. 2. Modify the data in the customers table to change the state for customers with ID number 2, 4, and 5 to NV. 3. Create a sequence that starts with -100 and increments by 10. Show the first value of the sequence. 4. Create a table named MYDATA with the following columns: id (primary key) and...
Please in C++, show screenshots of output plus .txt file. thanks Breakfast Billing System Write a...
Please in C++, show screenshots of output plus .txt file. thanks Breakfast Billing System Write a program to help a local restaurant automate its breakfast billing system. The program should do the following: Show the customer the different breakfast items offered by the restaurant. Allow the customer to select more than one item from the menu. Calculate and print the bill Assume that the restaurant offers the following breakfast items (the price of each item is shown to the right...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT