Question: This is unix, Pls provide a makefile for this program, Thanks. #include #include using namespace std; // main function definition with command line argument int

This is unix, Pls provide a makefile for this program, Thanks.

#include #include using namespace std;

// main function definition with command line argument int main(int argc, char** argv) { // Checks if number of command line argument is one then display error message if(argc == 1) cout<<" ERROR: No command line arguments.";

// Checks if number of command line argument is 3 else if(argc == 3) // Then display the first command line argument as Command // And second command line argument as Argument cout<<" Command: "<

// Otherwise checks if number of command line argument is 4 else if(argc == 4) { // Stores the length of second command line argument int len = strlen(argv[2]);

// Checks if length is less than 3 if(len < 3) { // Checks if second command line argument first character is '-' if(argv[2][0] == '-') cout<<" Command: "<

// Checks if second command line argument first character is '>' or '<' // or compares the second command line argument with ">>" else if(argv[2][0] == '>' || argv[2][0] == '<') cout<<" Command: "<

// Checks if second command line argument first character is '|' else if(argv[2][0] == '|') cout<<" Command: "<

// Otherwise display the following double option else cout<<" Command: "<

// Otherwise checks if number of command line argument is greater than 4 else if(argc > 4) { // Loops number of arguments for(int x = 1; x < argc; x++) { // Checks if the current argument is "ls" or "sort" or "wc" if(strcasecmp(argv[x], "ls") == 0 || strcasecmp(argv[x], "sort") == 0 || strcasecmp(argv[x], "wc") == 0) cout<<" Command: "<' or '<' // or compares the second command line argument with ">>" if(argv[x][0] == '<' || argv[x][0] == '>') cout<<" File Redirection: "<

// Checks if current command line argument first character is '|' else if(argv[x][0] == '-') cout<<" Option "<' or '<' // or compares the second command line argument with ">>" if(argv[x][0] == '<' || argv[x][0] == '>') cout<<" File Redirection: "<

// Otherwise else { // Stores the length of current command line argument int len = strlen(argv[x]); // Extracts the character at length - 4 from current command line argument char ch = argv[x][len-4]; // Checks if the character is '.' then display file if(ch == '.') cout<<" File : "<

Sample Output 1:

Command: touch Argument: sample.txt

Sample Output 2:

Command: ls Option: i Argument: sample.txt

Sample Output 3:

Command: ls Option: l Option: a Argument: $HOME

Sample Output 4:

Command: ls Option l Option a Arguments: $HOME

Sample Output 5:

Command: sort File Redirection: < File : sample.txt

Sample Output 6:

Command: sort File Redirection: < File : input.txt File Redirection: > File : output.txt

Sample Output 7:

Command: ls Pipe Command: sort

Sample Output 8:

Command: ls Pipe Command: sort Pipe Command: wc

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!