我必须查看大文件的最后几行(典型大小为500MB-2GB).我正在tail为Windows Powershell 寻找相当于Unix的命令.一些可供选择的是,
http://tailforwin32.sourceforge.net/
和
Get-Content [filename] | Select-Object -Last 10
对我来说,不允许使用第一种替代方案,第二种方案是缓慢的.有没有人知道PowerShell的尾部有效实现.
我必须从批处理文件中调用PowerShell脚本.脚本的一个参数是布尔值:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -NoProfile -File .\RunScript.ps1 -Turn 1 -Unify $false
Run Code Online (Sandbox Code Playgroud)
该命令失败,并显示以下错误:
Cannot process argument transformation on parameter 'Unify'. Cannot convert value "System.String" to type "System.Boolean", parameters of this type only accept booleans or numbers, use $true, $false, 1 or 0 instead.
At line:0 char:1
+ <<<< <br/>
+ CategoryInfo : InvalidData: (:) [RunScript.ps1], ParentContainsErrorRecordException <br/>
+ FullyQualifiedErrorId : ParameterArgumentTransformationError,RunScript.ps1
Run Code Online (Sandbox Code Playgroud)
截至目前,我在我的脚本中使用字符串进行布尔转换.但是如何将布尔参数传递给PowerShell?
我需要检查通过SQLCMD实用程序运行的查询的退出状态(成功/失败).例如,我连接的服务器没有数据库名称EastWind.然后,下面的命令失败并显示消息...
> "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE"
-S ZEPHIR -E -Q "USE WestWind"
Changed database context to 'WestWind'.
> echo %errorlevel%
0
> "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\SQLCMD.EXE"
-S ZEPHIR -E -Q "USE EastWind"
Database 'EastWind' does not exist. Make sure that the name is entered correctly
> echo %errorlevel%
0
Run Code Online (Sandbox Code Playgroud)
我看到两种情况下的返回值都是相同的.如何检查命令是否失败SQLCMD?
我有一个C++代码,它有3个数组声明.
float A[NUM];
float B[NUM];
float C[NUM];
当我编译时NUM=512,编译很快
time g++ -DNUM=512 trials trials.cpp -lm
0.16s user 0.04s system 94% cpu 0.219 total
NUM=167772160
time g++ -DNUM=167772160 trials trials.cpp -lm
7.90s user 0.69s system 99% cpu 8.604 total
但是,当我编译时
float A[NUM];
float B[NUM];
float C[NUM];
,需要更多时间.
NUM=512
time g++ -DNUM=512 trials trials.cpp -lm
0.16s user 0.04s system 94% cpu 0.219 total
NUM=167772160
我多年没用过C++了.我很想知道为什么编译时存在时间差,尽管编译后的目标文件大小相同.
我有类型类,对于所有这些类我都希望有一些常见的行为.我的问题在以下代码中解释:
class A a
class B b
class X x where
method :: (A a, B b) => x -> a -> b
data T = L | M | N
data U = P | Q | R
instance A T
instance B U
data Y = ZZZ
instance X Y where
method _ L = P
method _ M = Q
method _ N = R
当我加载此模块时,我收到以下错误:
example.hs:19:14:
Could not deduce (a ~ T)
from the context (A … 关于如何对powershell脚本的参数强制执行以下约束,我需要一些帮助.我可以在该param部分中指定这些约束.
例如,(只是一个例子,它不是我正在做的)对于一个被调用的脚本ReadPlainText.ps1,我只想给出两个参数中的任何一个:Lines或者Chars,但不是两者.该命令ReadPlainText.ps1 Sample.txt -Lines 20 -Chars 10应该导致错误.同样,该命令ReadPlainText.ps1 Sample.txt应该导致错误.
powershell ×3
c++ ×1
dos ×1
g++ ×1
haskell ×1
scripting ×1
sql-server ×1
sqlcmd ×1
tail ×1
windows ×1