在我的 Windows 计算机家庭桌面上,我右键单击属性下的 C:\Windows 文件夹,它显示:

如果我使用Microsoft sysinternals提供的du工具
du C:\Windows
Run Code Online (Sandbox Code Playgroud)
这产生
Files: 77060
Directories: 21838
Size: 31,070,596,369 bytes
Size on disk: 31,151,837,184 bytes
Run Code Online (Sandbox Code Playgroud)
如果我以管理员身份运行相同的命令
Files: 77894
Directories: 22220
Size: 32,223,507,961 bytes
Size on disk: 32,297,160,704 bytes
Run Code Online (Sandbox Code Playgroud)
以管理员身份运行 Powershell ISE 后,我从这个SO 答案中运行了以下 powershell 片段
"{0:N2}" -f ((Get-ChildItem -path C:\InsertPathHere -recurse | Measure-Object -property length -sum ).sum /1MB) + " MB"
Run Code Online (Sandbox Code Playgroud)
哪个输出
22,486.11 MB
Run Code Online (Sandbox Code Playgroud)
以管理员身份运行的命令提示符中的以下SO 答案中的 C# 代码返回:
35,163,662,628 bytes
Run Code Online (Sandbox Code Playgroud)
尽管关闭它仍然显示与 Windows 资源管理器不同。因此,这些方法都没有返回目录的实际大小。所以我的问题是这个。
是否有脚本或编码方法可以返回 C:\Windows …
我有一个包含数千行文本的文本文件,如下所示.
123 hello world
124 foo bar
125 hello world
Run Code Online (Sandbox Code Playgroud)
我想通过检查该行的子部分来测试重复项.对于上面它应该输出:
123 hello world
124 foo bar
Run Code Online (Sandbox Code Playgroud)
是否有可以执行此操作的vim命令?
更新:我在Windows机器上,所以不能使用uniq
我无法理解为什么以下PowerShell无法正常工作:
([regex]"(^|\D)(\d{6})(\D|$)").Matches( "123456 123457" ).Value
Run Code Online (Sandbox Code Playgroud)
上面代码生成:
123456
Run Code Online (Sandbox Code Playgroud)
为什么它不匹配这两个数字?
我最初使这个问题变得过于复杂,现在我想简化一下:
Microsoft是否有可能,更重要的是,由Microsoft正式支持我引用ValidateScript部分中的参数而不是要验证的参数?
这是我想做的:
function test
{
Param(
[switch]
$doThingA = $False,
[ValidateScript({
If( $doThingA -eq $True -and -not ( Test-Path $_ -PathType Leaf ) )
{
Write-Output $False
}
Write-Output $True
})]
[string]
$doThingA_FilePath
)
}
Run Code Online (Sandbox Code Playgroud)
这是Powershell的文档中有关ValidateScript参数的内容
当您使用ValidateScript属性时,正在验证的参数值将映射到$ _变量。您可以使用$ _变量来引用脚本中的参数值。
在过去的一周里,我一直在研究一些Powershell最佳实践.其中之一是重用Powershell参数名称,使命令更直观.
有没有人有检索所有函数的参数名称的功能?
我已在Windows XP计算机上安排批处理文件,以从网络共享中复制大量文本文件.下次运行此任务时,文件将被覆盖.批处理文件是这样的
copy \\networkshare1\*.txt C:\monitoring\files\
copy \\networkshare2\*.txt C:\monitoring\files\
Run Code Online (Sandbox Code Playgroud)
然后我使用Perl来分析文件.我想知道的是,如果有一种简单的方法,无需更改文件名,就可以记录文件从网络共享中复制的时间,以便我的Perl脚本知道它是使用旧版本还是新版本文件.
在数据库A中,我编写了一个名为的PL/SQL过程is_document_valid.从这个过程我想在数据库B中调用另一个PL/SQL过程.像这样的东西:
procedure is_document_valid( p_url varchar2( 200 ) )
-- call stored-procedure in another database
check_document( p_url );
end;
Run Code Online (Sandbox Code Playgroud)
有谁知道如何做到这一点?
所以我有一个使用点源的脚本
$Dependencies = "Script1","Script2","Script3"
$Dependencies | % { . ".\$( $_ ).ps1" }
Run Code Online (Sandbox Code Playgroud)
我尝试使用Try { } Catch { }捕获错误但将脚本导入 try 和 catch 的范围。
检测点源导入失败的最简洁方法是什么?
通常我可以设置ErrorAction为Stop并强制函数抛出错误,但我似乎无法通过点源来做到这一点。
更新
最后证明 try and catch 确实有效。这是我修改后的脚本
$Dependencies = "Script1","Script2","Script3"
$Dependencies |
ForEach-Object {
Try { . ".\$( $_ ).ps1" }
Catch { Throw }
}
Run Code Online (Sandbox Code Playgroud) 我确信这真的很简单,但为什么以下不起作用.
var o = function() { };
o.prototype.print = function( ) { console.log("hi") };
o.print(); // console message: Object function o() { } has no method 'print'
Run Code Online (Sandbox Code Playgroud)
在这里小提琴
UPDATE
为什么这也行不通
var o = function() { };
o.prototype.print = function( ) { console.log("hi") };
var c = Object.create( o );
c.print();
Run Code Online (Sandbox Code Playgroud)
如有必要,我可以开始一个新问题.
powershell ×4
windows ×2
batch-file ×1
database ×1
directory ×1
filesystems ×1
javascript ×1
oracle ×1
perl ×1
plsql ×1
regex ×1
validation ×1
vim ×1
windows-xp ×1