字符串分割
cut -f1 -d'/'
字符串分割2
| awk '{print $2}'
分割后文件名,批量mv
cut -f1 -d'/' | xargs -I {} mv {} ./xxxx/{}
grep文件差异比较(相对粗糙)
cat file1 | grep -v -f file2
liunx遍历文件
#include <dirent.h>
std::vector<std::string> listFiles(std::string folder)
{
std::vector<std::string> names;
DIR* dir = opendir(folder.c_str());//打开指定目录
dirent* p = NULL;//定义遍历指针
while((p = readdir(dir)) != NULL)//开始逐个遍历
{
//这里需要注意,linux平台下一个目录中有"."和".."隐藏文件,需要过滤掉
if(p->d_name[0] != '.' && //d_name是一个char数组,存放当前遍历到的文件名
p->d_type != DT_DIR)
{
string name = folder + string(p->d_name);
names.push_back(name);
//cout<<name<<endl;
}
}
closedir(dir);//关闭指定目录
return names;
}