Advertisement
Lixard

CW_OS

May 25th, 2019
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 20.30 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <Windows.h>
  4. //#include <vector>
  5. //#include <algorithm>
  6. //#include <iterator>
  7. #include <sstream>
  8. #include <fstream>
  9. #include <array>
  10. #include <filesystem>
  11.  
  12.  
  13. using namespace std;
  14. namespace fs = std::experimental::filesystem;
  15.  
  16. void ru_lang();
  17. void dir();
  18. void parser(string&, vector<string>&);
  19. void wordsToVector(const string&, vector<string>&);
  20. void main_cycle();
  21. void mkdir_command(vector<string>&);
  22. void comm_command(vector<string>&);
  23. void comm_cycle(const vector<string>&, const bool&, const bool&, const bool&, string& filename, int& writing);
  24. void diff_command(vector<string>&);
  25. void diff_out(const vector<string>&, const vector<string>&);
  26. void sort_command(vector<string>&);
  27. void sorting_out(vector<string>&, int& writing, string& filename);
  28. void uniq_command(vector<string>&);
  29. void wc_command(vector<string>&);
  30. void wcCouter(string&, const bool&, const bool&, const bool&, int&, string& filename, const bool& file, const string& name);
  31. void cd_command(vector<string>&);
  32. string fileToString(const string&);
  33. void fileToVector(const string&, vector<string>&);
  34. int writingToFileCheck(vector<string>&, string&);
  35. void helpRealize(array<string,7>&);
  36.  
  37. int main()
  38. {
  39.     ru_lang();
  40.     SetCurrentDirectory("D:\\");
  41.     main_cycle();
  42.     cout << "Работа терминала завершена" << endl;
  43.     system("PAUSE");
  44.     return 0;
  45. }
  46. void main_cycle()
  47. {
  48.     string input;
  49.     array<string, 8> commands = { "mkdir", "comm", "diff", "sort", "uniq", "wc", "cd", "e" };
  50.     array<string, 7> helping;
  51.     helpRealize(helping);
  52.     vector<string> v_input;
  53.     int key = 10;
  54.     dir();
  55.     while (getline(cin, input) && input != "quit")
  56.     {
  57.         bool help = false;
  58.         bool write = false;
  59.         bool rewrite = false;
  60.         parser(input, v_input);
  61.         for (unsigned int i = 0; i < commands.size(); i++)
  62.         {
  63.             if (v_input[0] == commands[i])
  64.             {
  65.                 key = i;
  66.             }
  67.         }
  68.         if (find(v_input.begin(), v_input.end(), ">>") != v_input.end())
  69.         {
  70.             write = true;
  71.         }
  72.         else if (find(v_input.begin(), v_input.end(), ">") != v_input.end())
  73.         {
  74.             rewrite = true;
  75.         }
  76.         if (find(v_input.begin(), v_input.end(), "--help") != v_input.end())
  77.         {
  78.             help = true;
  79.             if (key < 7)
  80.             {
  81.                 cout << helping[key];
  82.                 dir();
  83.             }
  84.         }
  85.         if (!help)
  86.         {
  87.             switch (key)
  88.             {
  89.             case 0: // mkdir // В линуксе разделителем папок является '/'
  90.                 mkdir_command(v_input);
  91.                 break;
  92.             case 1: // comm
  93.             {
  94.                 comm_command(v_input);
  95.                 break;
  96.             }
  97.             case 2: // diff
  98.             {
  99.                 diff_command(v_input);
  100.                 break;
  101.             }
  102.             case 3: // sort
  103.             {
  104.                 sort_command(v_input);
  105.                 break;
  106.             }
  107.             case 4: // uniq
  108.             {
  109.                 uniq_command(v_input);
  110.                 break;
  111.             }
  112.             case 5: // wc
  113.                 wc_command(v_input);
  114.                 break;
  115.             case 6: // cd  
  116.                 cd_command(v_input);
  117.                 break;
  118.             case 7: // пустой ввод
  119.                 dir();
  120.                 break;
  121.             default:
  122.                 cout << v_input[0] << ": команда не найдена" << endl;
  123.                 dir();
  124.                 break;
  125.             }
  126.         }
  127.         v_input.clear();
  128.         key = 10;
  129.     }
  130. }
  131.  
  132. void parser(string& input,vector<string>& v_input)
  133. {
  134.     if (input.empty())
  135.     {
  136.         input.push_back('e');
  137.     }
  138.     wordsToVector(input, v_input);
  139. }
  140.  
  141. void wordsToVector(const string& str, vector<string>& vec)
  142. {
  143.     istringstream is(str);        //превращаем строку в поток
  144.     copy(istream_iterator<string>(is), istream_iterator<string>(), back_inserter(vec)); //читаем по словам и добавляем в вектор
  145. }
  146.  
  147. void mkdir_command(vector<string>& v_input)
  148. {
  149.     v_input.erase(v_input.begin());
  150.     for (unsigned int i = 0; i < v_input.size(); i++)
  151.     {
  152.         if (!v_input[i].find('-'))
  153.         {
  154.             v_input.erase(v_input.begin() + i);
  155.             i--;
  156.         }
  157.     }
  158.     if (v_input.empty()) // при вводе только команды
  159.     {
  160.         cout << "mkdir: пропущен операнд" << endl;
  161.         cout << "По команде «mkdir --help» можно получить дополнительную информацию." << endl;
  162.     }
  163.     for (unsigned int i = 0; i < v_input.size(); i++)
  164.     {
  165.         string clearinput = v_input[0];
  166.         v_input[i].erase(remove(v_input[i].begin(), v_input[i].end(), '\\'), v_input[i].end());
  167.         const char* folder = v_input[i].c_str();
  168.         bool flag = true;
  169.         if(fs::exists(folder))
  170.         {
  171.             cout << "mkdir: невозможно создать каталог «" << clearinput << "»: Файл существует" << endl;
  172.             flag = false;
  173.         }
  174.         if (fs::create_directories(folder))
  175.         {
  176.             flag = false;
  177.         }
  178.         if (flag)
  179.         {
  180.             cout << "mkdir: невозможно создать каталог «" << clearinput << "»: Нет такого файла или каталога" << endl;
  181.         }
  182.     }
  183.     dir();
  184. }
  185.  
  186. void comm_command(vector<string>& v_input)
  187. {
  188.     string filename;
  189.     int writing = writingToFileCheck(v_input, filename);
  190.     v_input.erase(v_input.begin());
  191.     bool column1 = true;
  192.     bool column2 = true;
  193.     bool column3 = true;
  194.     if (v_input.size() < 2)
  195.     {
  196.         cout << "comm: пропущен операнд" << endl
  197.             << "По команде «comm --help» можно получить дополнительную информацию.";
  198.     }
  199.     else if (v_input.size() > 2)
  200.     {
  201.         if (find(v_input.begin(), v_input.end(), "-1") != v_input.end())
  202.         {
  203.             column1 = false;
  204.         }
  205.         if (find(v_input.begin(), v_input.end(), "-2") != v_input.end())
  206.         {
  207.             column2 = false;
  208.         }
  209.         if (find(v_input.begin(), v_input.end(), "-3") != v_input.end())
  210.         {
  211.             column3 = false;
  212.         }
  213.         if (find(v_input.begin(), v_input.end(), "-12") != v_input.end())
  214.         {
  215.             column1 = false;
  216.             column2 = false;
  217.         }
  218.         if (find(v_input.begin(), v_input.end(), "-13") != v_input.end())
  219.         {
  220.             column1 = false;
  221.             column3 = false;
  222.         }
  223.         if (find(v_input.begin(), v_input.end(), "-23") != v_input.end())
  224.         {
  225.             column2 = false;
  226.             column3 = false;
  227.         }
  228.         for (unsigned int i = 0; i < v_input.size(); i++)
  229.         {
  230.             if (!v_input[i].find('-'))
  231.             {
  232.                 v_input.erase(v_input.begin() + i);
  233.                 i--;
  234.             }
  235.         }
  236.         comm_cycle(v_input, column1, column2, column3, filename, writing);
  237.     }
  238.     else if (v_input.size() == 2)
  239.     {
  240.         comm_cycle(v_input, column1, column2, column3, filename, writing);
  241.     }
  242.  
  243. }
  244.  
  245. void comm_cycle(const vector<string>& v_input, const bool& column1, const bool& column2, const bool& column3, string& filename, int& writing)
  246. {
  247.     vector<string> file1, file2, out1, out2, out3;
  248.     string str;
  249.     string path = v_input[0];
  250.     ifstream file;
  251.     file.open(path);
  252.     if (file.is_open())
  253.     {
  254.         fileToVector(path, file1);
  255.         file.close();
  256.     }
  257.     else
  258.     {
  259.         cout << "comm: " << v_input[0] << ": Нет такого файла или каталога" << endl;
  260.     }
  261.     path = v_input[1];
  262.     file.open(path);
  263.     if (file.is_open())
  264.     {
  265.         fileToVector(path, file2);
  266.         file.close();
  267.     }
  268.     else
  269.     {
  270.         cout << "comm: " << v_input[1] << ": Нет такого файла или каталога" << endl;
  271.     }
  272.     int maxSize = file2.size();
  273.     if (file1.size() <= file2.size())
  274.     {
  275.         file1.resize(maxSize);
  276.     }
  277.     else if (file1.size() > file2.size())
  278.     {
  279.         maxSize = file1.size();
  280.         file2.resize(maxSize);
  281.     };
  282.     for (int i = 0; i < maxSize; i++)
  283.     {
  284.         if (file1[i] == file2[i])
  285.         {
  286.             out2.push_back(file1[i]);
  287.         }
  288.         if (file1[i] != file2[i])
  289.         {
  290.             out1.push_back(file1[i]);
  291.             out3.push_back(file2[i]);
  292.         }
  293.     }
  294.  
  295.     out1.resize(maxSize);
  296.     out2.resize(maxSize);
  297.     out3.resize(maxSize);
  298.     if (writing == 0)
  299.     {
  300.         for (int i = 0; i < maxSize; i++)
  301.         {
  302.             if (column1)
  303.             {
  304.                 cout << out1[i] << '\t';
  305.             }
  306.             if (column2)
  307.             {
  308.                 cout << out2[i] << '\t';
  309.             }
  310.             if (column3)
  311.             {
  312.                 cout << out3[i];
  313.             }
  314.             cout << endl;
  315.         }
  316.     }
  317.     else if (writing == 1)
  318.     {
  319.         ofstream fout;
  320.         fout.open(filename, ios::trunc);
  321.         for (int i = 0; i < maxSize; i++)
  322.         {
  323.             if (column1)
  324.             {
  325.                 fout << out1[i] << '\t';
  326.             }
  327.             if (column2)
  328.             {
  329.                 fout << out2[i] << '\t';
  330.             }
  331.             if (column3)
  332.             {
  333.                 fout << out3[i];
  334.             }
  335.             fout << endl;
  336.         }
  337.     }
  338.     else if (writing == 2)
  339.     {
  340.         ofstream fout;
  341.         fout.open(filename, ios::app);
  342.         for (int i = 0; i < maxSize; i++)
  343.         {
  344.             if (column1)
  345.             {
  346.                 fout << out1[i] << '\t';
  347.             }
  348.             if (column2)
  349.             {
  350.                 fout << out2[i] << '\t';
  351.             }
  352.             if (column3)
  353.             {
  354.                 fout << out3[i];
  355.             }
  356.             fout << endl;
  357.         }
  358.     }
  359.     cout << endl;
  360.     dir();
  361. }
  362.  
  363. void diff_command(vector<string>& v_input)
  364. {
  365.     v_input.erase(v_input.begin());
  366.     vector<string> file1, file2, out1, out2;
  367.     string str;
  368.     string path = v_input[0];
  369.     ifstream file;
  370.     file.open(path);
  371.     if (file.is_open())
  372.     {
  373.         fileToVector(path, file1);
  374.         file.close();
  375.     }
  376.     else
  377.     {
  378.         cout << "diff: " << v_input[0] << ": Нет такого файла или каталога" << endl;
  379.     }
  380.     path = v_input[1];
  381.     file.open(path);
  382.     if (file.is_open())
  383.     {
  384.         fileToVector(path, file2);
  385.         file.close();
  386.     }
  387.     else
  388.     {
  389.         cout << "diff: " << v_input[1] << ": Нет такого файла или каталога" << endl;
  390.     }
  391.     unsigned int maxSize = file1.size();
  392.     if (maxSize > file2.size())
  393.     {
  394.         file2.resize(maxSize);
  395.     }
  396.     else if (maxSize < file2.size())
  397.     {
  398.         maxSize = file2.size();
  399.         file1.resize(maxSize);
  400.     }
  401.     for (unsigned int i = 0; i < maxSize; i++)
  402.     {
  403.             if (file1[i] != file2[i])
  404.             {
  405.                 out2.push_back(file2[i]);
  406.                 out1.push_back(file1[i]);
  407.             }
  408.     }
  409.     diff_out(out1, out2);
  410.     dir();
  411. }
  412.  
  413. void diff_out(const vector<string>& out1, const vector<string>& out2)
  414. {
  415.     for (auto element : out1)
  416.     {
  417.         cout << "< " << element << endl;
  418.     }
  419.     cout << "---" << endl;
  420.     for (auto element : out2)
  421.     {
  422.         cout << "> " << element << endl;
  423.     }
  424. }
  425.  
  426. void cd_command(vector<string>& v_input)
  427. {
  428.     v_input.erase(v_input.begin());
  429.     if (v_input.size() < 1)
  430.     {
  431.         v_input.push_back("0");
  432.         SetCurrentDirectory("D:\\");
  433.     }
  434.     if (!(v_input[0] == "0"))
  435.     {
  436.         const char* p = v_input[0].c_str();
  437.         bool flag = true;
  438.         if (v_input.size() > 1)
  439.         {
  440.             cout << "cd: слишком много аргументов" << endl;
  441.             flag = false;
  442.         }
  443.         if (flag)
  444.         {
  445.             if (!SetCurrentDirectory(p))
  446.             {
  447.                 cout << "cd: " << p << ": Нет такого файла или каталога" << endl;
  448.             }
  449.         }
  450.  
  451.     }
  452.     dir();
  453. }
  454.  
  455. void sort_command(vector<string>& v_input)
  456. {
  457.     string filename;
  458.     int writing = writingToFileCheck(v_input, filename);
  459.     v_input.erase(v_input.begin());
  460.     vector<string> lines;
  461.     string str;
  462.     if (v_input.size() == 0)
  463.     {
  464.         while (getline(cin, str, '\n'))
  465.         {
  466.             lines.push_back(str);
  467.         }
  468.         cin.clear();
  469.         sorting_out(lines, writing, filename);
  470.     }
  471.     while (v_input.size() != 0)
  472.     {
  473.         string path = v_input[0];
  474.         v_input.erase(v_input.begin());
  475.         ifstream file(path);
  476.         if (file.is_open())
  477.         {
  478.             fileToVector(path, lines);
  479.             sorting_out(lines, writing, filename);
  480.             file.close();
  481.         }
  482.         else
  483.         {
  484.             cout << "sort: не удалось прочитать: " << v_input[0] << ": Нет такого файла или каталога";
  485.         }
  486.     }
  487.     cout << endl;
  488.     dir();
  489. }
  490.  
  491. void sorting_out(vector<string>& lines, int& writing, string& filename)
  492. {
  493.     sort(lines.begin(), lines.end());
  494.     if (writing == 0)
  495.     {
  496.         copy(lines.begin(), lines.end(), ostream_iterator<string>(cout, "\n"));
  497.     }
  498.     else if (writing == 1)
  499.     {
  500.         ofstream fout;
  501.         fout.open(filename, ios::trunc);
  502.         copy(lines.begin(), lines.end(), ostream_iterator<string>(fout, "\n"));
  503.     }
  504.     else if (writing == 2)
  505.     {
  506.         ofstream fout;
  507.         fout.open(filename, ios::app);
  508.         copy(lines.begin(), lines.end(), ostream_iterator<string>(fout, "\n"));
  509.     }
  510. }
  511.  
  512. void uniq_command(vector<string>& v_input)
  513. {
  514.     string filename;
  515.     int writing = writingToFileCheck(v_input, filename);
  516.     v_input.erase(v_input.begin());
  517.     string str;
  518.     vector<string> lines;
  519.     if (v_input.size() == 0)
  520.     {
  521.         string strf;
  522.         while (getline(cin, str, '\n'))
  523.         {
  524.             if (strf != str)
  525.             {
  526.                 cout << str << endl;
  527.             }
  528.             strf = str;
  529.         }
  530.         cin.clear();
  531.     }
  532.     else if (v_input.size() == 1)
  533.     {
  534.         string path = v_input[0];
  535.         ifstream file(path);
  536.         if (file.is_open())
  537.         {
  538.             fileToVector(path, lines);
  539.             auto x = unique(lines.begin(), lines.end());
  540.             lines.erase(x, lines.end());
  541.             if (writing == 0)
  542.             {
  543.                 copy(lines.begin(), lines.end(), ostream_iterator<string>(cout, "\n"));
  544.             }
  545.             else if (writing == 1)
  546.             {
  547.                 ofstream fout;
  548.                 fout.open(filename, ios::trunc);
  549.                 copy(lines.begin(), lines.end(), ostream_iterator<string>(fout, "\n"));
  550.             }
  551.             else if (writing == 2)
  552.             {
  553.                 ofstream fout;
  554.                 fout.open(filename, ios::app);
  555.                 copy(lines.begin(), lines.end(), ostream_iterator<string>(fout, "\n"));
  556.             }
  557.         }
  558.         else
  559.         {
  560.             cout << "uniq: " << v_input[0] << ": Нет такого файла или каталога";
  561.         }
  562.     }
  563.     else if (v_input.size() > 1)
  564.     {
  565.         cout << "uniq: лишний операнд " << endl
  566.             << "По команде «uniq --help» можно получить дополнительную информацию.";
  567.     }
  568.     cout << endl;
  569.     dir();
  570. }
  571.  
  572. void wc_command(vector<string>& v_input)
  573. {
  574.     string filename;
  575.     int writing = writingToFileCheck(v_input, filename);
  576.     v_input.erase(v_input.begin());
  577.     string str;
  578.     bool Isfile = false;
  579.     bool c = false;
  580.     bool l = false;
  581.     bool w = false;
  582.     if (find(v_input.begin(), v_input.end(), "-c") != v_input.end())
  583.     {
  584.         c = true;
  585.     }
  586.     if (find(v_input.begin(), v_input.end(), "-l") != v_input.end())
  587.     {
  588.         l = true;
  589.     }
  590.     if (find(v_input.begin(), v_input.end(), "-w") != v_input.end())
  591.     {
  592.         w = true;
  593.     }
  594.     if (!c && !l && !w)
  595.     {
  596.         c = true;
  597.         l = true;
  598.         w = true;
  599.     }
  600.     for (unsigned int i = 0; i < v_input.size(); i++)
  601.     {
  602.         if (!v_input[i].find('-'))
  603.         {
  604.             v_input.erase(v_input.begin() + i);
  605.             i--;
  606.         }
  607.     }
  608.     vector<string>::iterator position = find(v_input.begin(), v_input.end(), "*.txt");
  609.     if (position != v_input.end())
  610.     {
  611.         v_input.erase(position);
  612.         string path;
  613.         WIN32_FIND_DATA FindFileData;
  614.         HANDLE hf;
  615.         path = fs::current_path().u8string();
  616.         path += "\\*.txt";
  617.         hf = FindFirstFile(path.c_str() , &FindFileData);
  618.         if (hf != INVALID_HANDLE_VALUE)
  619.         {
  620.             do
  621.             {
  622.                 v_input.push_back(FindFileData.cFileName);
  623.             }
  624.             while (FindNextFile(hf, &FindFileData) != 0);
  625.             FindClose(hf);
  626.         }
  627.     }
  628.     if (v_input.size() == 0)
  629.     {
  630.         string path = "";
  631.         getline(cin, str, '\0');
  632.         cin.clear();
  633.         wcCouter(str, c, l, w, writing, filename, Isfile, path);
  634.     }
  635.     while (v_input.size() != 0)
  636.     {
  637.         Isfile = true;
  638.         string path = v_input[0];
  639.         ifstream file(path);
  640.         if (file.is_open())
  641.         {
  642.             str = fileToString(path);
  643.             wcCouter(str, c, l, w, writing, filename, Isfile, path );
  644.             file.close();
  645.         }
  646.         else
  647.         {
  648.             cout << "wc: " << v_input[0] << ": Нет такого файла или каталога";
  649.         }
  650.        
  651.         v_input.erase(v_input.begin());
  652.     }
  653.     cout << endl;  
  654.     dir();
  655. }
  656.  
  657. void wcCouter( string& str, const bool& c, const bool& l, const bool& w, int& writing, string& filename, const bool& Isfile, const string& name)
  658. {
  659.     int strings = 0;
  660.     int words = 0;
  661.     int size = str.length();
  662.     if (Isfile)
  663.     {
  664.         if (str[str.size() - 1] != '\n')
  665.         {
  666.             strings++;
  667.         }
  668.     }
  669.     for (unsigned int i = 0; i < str.length(); i++)
  670.     {
  671.         if (str[i] == '\n')
  672.         {
  673.             strings++;
  674.         }
  675.     }
  676.     istringstream is(str);
  677.     vector<string> word;
  678.     while (is >> str)
  679.     {
  680.         word.push_back(str);
  681.         words++;
  682.     }
  683.     if (writing == 0)
  684.     {
  685.         if (c)
  686.         {
  687.             cout << strings << '\t';
  688.         }
  689.         if (l)
  690.         {
  691.             cout << words << '\t';
  692.         }
  693.         if (w)
  694.         {
  695.             cout << size << '\t';
  696.         }
  697.         cout << name << endl;
  698.     }
  699.     else if (writing == 1)
  700.     {
  701.         ofstream fout;
  702.         fout.open(filename, ios::trunc);
  703.         if (c)
  704.         {
  705.             fout << strings << '\t';
  706.         }
  707.         if (l)
  708.         {
  709.             fout << words << '\t';
  710.         }
  711.         if (w)
  712.         {
  713.             fout << size << '\t';
  714.         }
  715.         fout << endl;
  716.     }
  717.     else if (writing == 2)
  718.     {
  719.         ofstream fout;
  720.         fout.open(filename, ios::app);
  721.         if (c)
  722.         {
  723.             fout << strings << '\t';
  724.         }
  725.         if (l)
  726.         {
  727.             fout << words << '\t';
  728.         }
  729.         if (w)
  730.         {
  731.             fout << size << '\t';
  732.         }
  733.         fout << endl;
  734.     }
  735. }
  736.  
  737. void ru_lang()
  738. {
  739.     SetConsoleCP(1251);
  740.     SetConsoleOutputCP(1251);
  741. }
  742.  
  743. void dir() // user:~/qwe$
  744. {
  745.     cout << "user:~" << fs::current_path() << "# ";
  746. }
  747.  
  748. string fileToString(const string& file)
  749. {
  750.     ifstream f(file);
  751.     stringstream ss;
  752.     ss << f.rdbuf();
  753.     return ss.str();
  754. }
  755.  
  756. void fileToVector(const string& file, vector<string>& vec)
  757. {
  758.     ifstream f(file);
  759.     string str;
  760.     while (getline(f, str, '\n'))
  761.     {
  762.         vec.push_back(str);
  763.     }
  764. }
  765.  
  766. int writingToFileCheck(vector<string>& v_input, string& filename)
  767. {
  768.     int result;
  769.     if (find(v_input.begin(), v_input.end(), ">>") != v_input.end())
  770.     {
  771.         result = 2;
  772.     }
  773.     else if (find(v_input.begin(), v_input.end(), ">") != v_input.end())
  774.     {
  775.         result = 1;
  776.     }
  777.     else
  778.     {
  779.         result = 0;
  780.     }
  781.     if (result == 2)
  782.     {
  783.         vector<string>::iterator position = find(v_input.begin(), v_input.end(), ">>");
  784.         if (position != v_input.end())
  785.         {
  786.             filename = v_input[distance(v_input.begin(), position + 1)];
  787.             v_input.erase(position, position + 2);
  788.         }
  789.     }
  790.     else if (result == 1)
  791.     {
  792.         vector<string>::iterator position = find(v_input.begin(), v_input.end(), ">");
  793.         if (position != v_input.end())
  794.         {
  795.             filename = v_input[distance(v_input.begin(), position + 1)];
  796.             v_input.erase(position, position + 2);
  797.         }
  798.     }
  799.     return result;
  800. }
  801. void helpRealize(array<string,7>& helping)
  802. {
  803.     //mkdir
  804.     helping[0] = "Использование: mkdir [КЛЮЧ]… КАТАЛОГ… \n\
  805. Создает КАТАЛОГ(и), если он ещё не существует.\n";
  806.     //comm
  807.     helping[1] = "Использование: comm [КЛЮЧ]… ФАЙЛ1 ФАЙЛ2\n\
  808. Сравнивает сортированные файлы ФАЙЛ1 и ФАЙЛ2 построчно.\n\
  809. \n\
  810. Если ФАЙЛ1 или ФАЙЛ2(но не оба) задан как - , читается стандартный ввод.\n\
  811. \n\
  812. При запуске без ключей выдает результат в три столбца.Первый столбец\n\
  813. содержит строки, уникальные для ФАЙЛА1, второй — уникальные для\n\
  814. ФАЙЛА2, а третий — общие для обоих файлов строки.\n\
  815. \n\
  816. - 1                      не показывать столбец 1 (строки, уникальные\n\
  817.             для ФАЙЛА1)\n\
  818. - 2                      не показывать столбец 2 (строки, уникальные\n\
  819.             для ФАЙЛА2)\n\
  820. - 3                      не показывать столбец 3 (строки, встреченные\n\
  821. в обоих файлах)\n";
  822.     //diff
  823.     helping[2] = "Использование: diff [КЛЮЧ]? ФАЙЛЫ\n\
  824. Построчно сравнивает ФАЙЛЫ.\n";
  825.     //sort
  826.     helping[3] = "Использование: sort [КЛЮЧ]… [ФАЙЛ]…\n\
  827. или:    sort[КЛЮЧ]… --files0 - from = Ф\n\
  828. Печатает сортированное слияние всех ФАЙЛ(ов) на стандартный вывод.\n";
  829.     //uniq
  830.     helping[4] = "Использование: uniq [КЛЮЧ]… [ВХОД [ВЫХОД]]\n\
  831. Фильтрует совпавшие строки из ВХОДА(или стандартного ввода),\n\
  832. записывая их в ВЫХОД(или стандартный вывод).\n";
  833.     //wc
  834.     helping[5] = "Использование: wc [КЛЮЧ]… [ФАЙЛ]…\n\
  835. или:    wc[КЛЮЧ]… --files0 - from = Ф\n\
  836. Печатает число символов новой строки, слов и байт для каждого ФАЙЛА и\n\
  837. итоговую строку, если было задано несколько ФАЙЛОВ.Словом считается\n\
  838. последовательность символов ненулевой длины, отделённая пробельным символом.\n\
  839. \n\
  840. Если ФАЙЛ не задан или задан как - , читает стандартный ввод.\n\
  841. \n\
  842. Для выбора выводимых счётчиков используются следующие параметры\n\
  843. (счётчики всегда выводятся в таком порядке : символы новой строки,\n\
  844. слова, символы, байты, максимальная длина строки) :\n\
  845. -c,             напечатать количество символов\n\
  846. -l,             напечатать количество новых строк\n\
  847. -w,     напечатать количество слов\n";
  848.     //cd
  849.     helping[6] = "cd: cd [-L|[-P [-e]] [-@]] [каталог]\n\
  850. Изменяет рабочую директорию оболочки.\n";
  851. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement