Answer to Question #315016 in C++ for NATH

Question #315016

1.   Write a Linux shell script that allow the user to enter a choice based on the following options: 

 

 

A – Delete a file in current directory B – Create a directory in current directory. 

C – Change a file access mode to 755. D – Rename a file to another name E – Copy a file to another directory. 

 

If the user entered any other choices than the above, prompt the user to pick only A – E. 

 

Provide the shell script along with the sample output screenshot. Refer to the attached rubrics as a guide. Print a copy of the rubrics to be attached with this lab report.  


1
Expert's answer
2022-03-21T12:40:25-0400
int main()
{
	string bd = "BD.txt";
	fstream fs;
	fstream fe;
	string str, msg, ftr, ltr, ntr, mtr, ktr;
	char ch, ce;
	string ster, sty;
	int y = 0, x, selectdata, savedata, loaddata, save = 0, i = 0, deletedata, e = 0;
	bool exit = false;
	const int size = 10;
	int arrx = 0;
	int enter1 = 0, enter2, enter3 = 0, enter4, enter5 = 0;
	double result; 
	vector<string> data = { "" };
	if (fs.peek() == EOF)
	{
		cout << "File BD empty" << endl;
		cin >> enter1;
		fs.close();
	}
	else
	{
		while (!fs.eof())
		{






			data[i] = (char*)malloc(sizeof(char) * size);
			fs >> data[i] >> ch;
			if (i > 0)
			{
				ster = ch + data[i];
				data[i] = ster;
			}
			ce = ch;
			cout << data[i] << "\0" << endl;
			i++;
			if (i > 0)
			{
				data.push_back("");
			}
		}


		cin >> loaddata;


		fe.open(data[loaddata]);


		while (fe.peek() == EOF)
		{
			cout << "File " << data[i] << "empty or does not exist!" << endl;
			cin >> enter1;
		}


		while (!fe.eof())
		{
			msg = "";
			getline(fe, msg);


			cout << msg << endl;
		}
		cin >> enter1;


		fe.close();
		fs.close();
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment