Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Byzer 提供更丰富和便利的文件系统操作支持 #1812

Open
allwefantasy opened this issue Aug 10, 2022 · 0 comments
Open

Byzer 提供更丰富和便利的文件系统操作支持 #1812

allwefantasy opened this issue Aug 10, 2022 · 0 comments

Comments

@allwefantasy
Copy link
Contributor

allwefantasy commented Aug 10, 2022

Byzer 在文件系统的操作能力比较薄弱,目前仅支持部分命令,诸如 !fs -ls , !fs mv 等常见能力。但现实中对文件系统的操作要求是很复杂的。比如这个需求:#1810 或者这个需求:https://zhuanlan.zhihu.com/p/552065988? 当然还有更复杂的需求。

有两个层面解决:

  1. 通过 ET 来根据具体需求解决。这个一般适合一些定制化或者非泛化的需求,是个不错的主意。
  2. 通过扩展 !fs 来解决,可以提供一些特有的选项,为了和以前的做区别,要求第一个参数是 utils.

举例:

!fs utils rename "/tmp/*.csv"   "/tmp/sub"  "(\\.csv)$"  ".txt"; 

用户也可以这么写:

!fs utils rename _ -source "/tmp/*.csv"  -target "/tmp/sub"  -pattern "(\\.csv)$"  -replace ".txt"; 

这表示需要对匹配到的所有 csv文件进行改名,改名后放到 "/tmp/sub" 目录下,改名的方式为正则修改原文件名称。没有匹配到的,则原封不动的移动到新的目录下。

这里的效果是,这里我们会将所有 .csv 后缀改成 .txt 后缀,同时保留文件名。

还有比如:

!fs utils getmerge "/tmp/*.csv" "/tmp/a.csv" 1;

表示合并所有文件(对除了第一个文件的每个待合并的文件去掉第一行),生成一个 a.csv文件,

也可以这么写:

!fs utils getmerge _  -source "/tmp/*.csv"  -target "/tmp/a.csv"  -skipNLines 1;
@allwefantasy allwefantasy changed the title Byzer 文件系统操作支持 Byzer 提供更丰富和便利的文件系统操作支持 Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants