gpt4 book ai didi

powershell - 用 Powershell 替换 MKS

转载 作者:行者123 更新时间:2023-12-02 23:31:48 25 4
gpt4 key购买 nike

有人可以将这两个脚本从 MKS 翻译成 Powershell 吗?我想从我们的 ETL 工具中删除 MKS 并使用 Powershell 完成此操作,但没有这些功能

1)
文件大小= ls -l $1 | awk '{print $5}'
如果 [ $FileSize -ge 100000000 ];然后
拆分 -b 60000000 $1 $1


2)
find $1 -type f -name *.txt -mtime +30 -exec rm {}\;

非常感谢
画了

最佳答案

避免在此处使用标准别名(例如,可以使用 dirls 而不是 Get-ChildItem ):

1) FileSize=ls -l $1 | awk '{print $5}'


$filesize = (Get-ChildItem $name).Length

if [ $FileSize -ge 100000000 ]; then split -b 60000000 $1 $1 fi


if ($filesize -ge 100000000) { ... }

(想不起来 split 的功能)

2) find $1 -type f -name *.txt -mtime +30 -exec rm {} \;


$t = [datetime]::Now.AddSeconds(-30)
Get-ChildItem -path . -recurse -filter *.txt |
Where-Object { $_.CreationTime -gt $t -and $_.PSIsContainer } |
Remove-Item

(将 -whatif 添加到 Remove-Item 以列出将要删除的内容而不删除它们。)

关于powershell - 用 Powershell 替换 MKS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5302734/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com