我正在更新一个旧脚本来解析ARP数据并从中获取有用的信息.我们添加了一个新的路由器,虽然我可以从路由器中提取ARP数据,但它是一种新的格式.我有一个文件"zTempMonth",它是来自两组路由器的所有arp数据,我需要编译成一个规范化的新数据格式.下面的代码行按逻辑方式执行我需要它们 - 但它非常慢 - 因为在以前脚本需要20-30分钟的情况下运行这些循环需要几天时间.有没有办法加快速度,或者找出减慢速度的方法?
先感谢您,
echo "Parsing zTempMonth"
while read LINE
do
wc=`echo $LINE | wc -w`
if [[ $wc -eq "6" ]]; then
true
out=$(echo $LINE | awk '{ print $2 " " $4 " " $6}')
echo $out >> zTempMonth.tmp
else
false
fi
if [[ $wc -eq "4" ]]; then
true
out=$(echo $LINE | awk '{ print $1 " " $3 " " $4}')
echo $out >> zTempMonth.tmp
else
false
fi
done < zTempMonth
Run Code Online (Sandbox Code Playgroud) 我正在尝试比较交换机型号(例如:2620-48-PWR,2848,5308xl,5412zl),因此我可以针对特定型号运行特定测试.当我运行脚本时,我收到错误:
tstVOIPConfigTest.bsh:第207行:5412zl:算术语法错误
但是这个页面:(http://www.softpanorama.org/Scripting/Shellorama/arithmetic_expressions.shtml)表示"Bash只是忽略任何不包含数值的字符串,并为包含数字和其他数字的任何内容生成错误人物:"
示例代码:
if [[ $switchModel -eq "2810-48G" ]]; then
echo "2810-48g Series Switch detected - verifying if qos-passthrough-mode is enabled" >> $errFile
test "qos-passthrough-mode typical" "qos-passthrough-mode typical set" "qos-passthrough-mode typical not set"
fi
Run Code Online (Sandbox Code Playgroud)
由于我的脚本是用bash编写的,我的问题是如何在bash本身(据我所知)不能满足我需要的时候完成我需要做的事情?
先感谢您,
我收到以下错误,我不明白为什么或它要求什么.
我试图在表格中显示的对象是:
function newURLObject()
{
# param ([String]$Value, [Int]$Count = "1", [String]$IP )
param ([String]$Value, [Int]$Count = "1" )
$obj = new-object PSObject
$obj | add-member -type NoteProperty -Name Value -Value $Value.substring(1)
$obj | add-member -type NoteProperty -Name Count -Value $Count
# $obj | add-member -type NoteProperty -Name IP -Value $IP
return $obj
}
Run Code Online (Sandbox Code Playgroud)
基本流程如下.
#< Declare Objects>
#< Code to create an array of those objects >
$z = @{Expression={$_.Count};Label="Count";width=5}, @{Expression={$_.Value};Label="URL";count=35}
$y = $listOfRequestedURLs | sort count -descending | …Run Code Online (Sandbox Code Playgroud)