返回列表 发帖

[问题求助] 如何让powershell gawk vbs 语言在一个脚本中执行

本帖最后由 娜美 于 2022-4-16 11:13 编辑

如何在powershell脚本里加入gawk语言执行

#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
gawk “!a[$0]++'‘ file COPY



如何在powershell脚本里加入vbs语言启动第三方脚本
#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
set ws=wscript.createobject("wscript.shell")
ws.run "tmp.bat",0COPY

请问如何把不同语言放在一个脚本里执行?  谢谢
#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
gawk “!a[$0]++'‘ file
set ws=wscript.createobject("wscript.shell")
ws.run "tmp.bat",0COPY

回复 2# idwma


   多谢大哥哥, 我会去看看的,   
还有在上面这些powershell脚本里可以支持混写不同语言吗   例如加入执行gawk命令,

TOP

回复 4# idwma

不算是脚本       只是加入一条awk命令  但是这样进入powershell后它是没法执行的,   目的是要怎样才可以兼容执行

#@&cls&powershell "type %~s0|out-string|iex"&pause&exit

gawk “!a[$0]++" file >1.txt

TOP

本帖最后由 娜美 于 2022-4-17 16:03 编辑

回复 6# idwma


    真没想到会是单双引号问题  谢谢了
还有一个现像    下面1.txt源編码是UFT-8  使用下面命令后竟然会默认变成UFT-16編码

#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
type 1.txt >0.txtCOPY


但在bat下输出默认是ANSI編码

难道在powershell 默认输出都是UFT-16編码?

TOP

回复 8# idwma


   好的  谢谢

TOP

回复 6# idwma
#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
gawk '!a[$0]++' 1.txt >out.txtCOPY
1.txt 是DOS uft-16编码,   为什么输出后会变成MAC uft-16编码,   而且全乱码了


out.txt输出可以默认是ANSI编码吗

TOP

TOP

本帖最后由 娜美 于 2022-4-22 13:59 编辑

idwma哥哥

例如  1.txt是ANSI编码   使用下面Powershell环境命令.  输出会是UTF-16编码的   请问有什么方法可以输出是ANSI编码吗
#@&cls&powershell "type %~s0|out-string|iex"&pause&exit
gawk '!a[$0]++' 1.txt >out.txt

TOP

本帖最后由 娜美 于 2022-4-22 18:36 编辑

回复 14# idwma


   原来这样可以  明白了  谢谢idwma哥

如果不覆盖out.txt文件呢   在后面追加写入       在bat脚本是>>  但是在powersehll环境不行的

这样用正确吗

gawk '!a[$0]++' 1.txt |sc Out-File  -Append out.txtCOPY

TOP

回复 16# idwma


  谢谢了   似乎ac更好

TOP

返回列表