00000010- 00 11 50 44 00 00 00 00 00 00 00 00 00 11 58 44 [..PD..........XD]
00000011- 00 00 00 00 00 00 00 00 00 11 80 44 00 00 00 00 [...........D....]
00000012- 00 00 00 00 00 11 88 44 00 00 00 00 00 00 00 00 [.......D........]
00000013- 00 11 90 44 00 00 00 00 00 00 00 00 00 11 98 44 [...D...........D]
00000014- 00 00 00 00 00 00 00 00 00 11 C0 44 00 00 00 00 [...........D....]
需要提取下面提到的十六进制值并将其复制到新文件 -
00 11 50 44 00 00 00 00 00 00 00 00 00 11 58 44 00 00 00 00 00 00 00 00 00 11 80 44 00 00 00 00 00 00 00 00 00 11 88 44 00 00 00 00 00 00 00 00 00 11 90 44 00 00 00 00 00 00 00 00 00 11 98 44 00 00 00 00 00 00 00 00 00 11 C0 44 00 00 00 00
答案 0 :(得分:2)
假设您已将所有十六进制数据存储在名为$input
的变量中,您可以获得一个十六进制数字列表,如下所示:
foreach line [split $input \n] {
foreach c [scan $line %*x-%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x%x] {
if {$c ne ""} {
lappend out [format %x $c]
}
}
}
之后,$out
包含十六进制数字列表。明智地使用它。
答案 1 :(得分:1)
这是另一种方法,它做出以下假设:
没有进一步的麻烦:
set hexList {}
foreach line [split $input "\n"] {
set hexList [concat $hexList [lrange $line 1 16]]
}
puts $hexList; # hexList now contains all the hex digits
答案 2 :(得分:0)
我的TCL有点生疏,但非常天真的方法是:
# Parse all hex numbers from your input variable into hexList
set hexList [regexp -all -inline -- {\d{2}(?:\s{1,2})} $input]
# Replace some spaces to get the expected output and store it into hexData
regsub -all -- {\s{3}} [join $hexList] { } hexData
# Write hexData into your file..