|
|
@ -133,22 +133,22 @@ System System::operator||(System rhs) |
|
|
|
return rhs; |
|
|
|
return rhs; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// cut -f
|
|
|
|
// cut -f -d
|
|
|
|
System& System::cut(uint32_t field) |
|
|
|
System& System::cut(uint32_t field, char delimiter) |
|
|
|
{ |
|
|
|
{ |
|
|
|
exec(); |
|
|
|
exec(); |
|
|
|
|
|
|
|
|
|
|
|
return apply([&field](std::vector<std::string>& lines) { |
|
|
|
return apply([&field, &delimiter](std::vector<std::string>& lines) { |
|
|
|
for (auto& line : lines) { |
|
|
|
for (auto& line : lines) { |
|
|
|
size_t count = 1; |
|
|
|
size_t count = 1; |
|
|
|
size_t index = 0; |
|
|
|
size_t index = 0; |
|
|
|
while (index != std::string::npos) { |
|
|
|
while (index != std::string::npos) { |
|
|
|
if (count == field) { |
|
|
|
if (count == field) { |
|
|
|
line = line.substr(0, line.find_first_of(" ")); |
|
|
|
line = line.substr(0, line.find_first_of(delimiter)); |
|
|
|
break; |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
index = line.find_first_of(" "); |
|
|
|
index = line.find_first_of(delimiter); |
|
|
|
line = line.substr(index + 1); |
|
|
|
line = line.substr(index + 1); |
|
|
|
count++; |
|
|
|
count++; |
|
|
|
} |
|
|
|
} |
|
|
|