awk:通过特定的分隔符删除字符串(awk: remove strings by specific delimiter)
我在文件中有几列,其中第二列有“:”分隔符,我想删除第二列中的第一,第三和第四个字符串,并在该列中留下第二个字符串。 但我有正常的分隔符空间,所以我不知道。
input: --- 22:16050075:A:G 16050075 A G --- 22:16050115:G:A 16050115 G A --- 22:16050213:C:T 16050213 C T --- 22:16050319:C:T 16050319 C T --- 22:16050527:C:A 16050527 C A desired output: --- 22 16050075 16050075 A G --- 22 16050115 16050115 G A --- 22 16050213 16050213 C T --- 22 16050319 16050319 C T --- 22 16050527 16050527 C A Wrong: cat df.txt | awk -F: '{print $1, $3, $6, $7, $8}' --- 22 A --- 22 G --- 22 C --- 22 C --- 22 C
但我做不到。 awk和sed命令可以做到吗?
谢谢。
I have few columns in a file, in which the second column has ":" delimiter and I would like to remove the first, third and fourth strings in the second column and left the second string in that column. But I have the normal delimiter space, so I have no idea.
input: --- 22:16050075:A:G 16050075 A G --- 22:16050115:G:A 16050115 G A --- 22:16050213:C:T 16050213 C T --- 22:16050319:C:T 16050319 C T --- 22:16050527:C:A 16050527 C A desired output: --- 22 16050075 16050075 A G --- 22 16050115 16050115 G A --- 22 16050213 16050213 C T --- 22 16050319 16050319 C T --- 22 16050527 16050527 C A Wrong: cat df.txt | awk -F: '{print $1, $3, $6, $7, $8}' --- 22 A --- 22 G --- 22 C --- 22 C --- 22 C
but I can not do it right. can awk and sed command can do it?
Thank you.
原文:https://stackoverflow.com/questions/42384007
最满意答案
只需调用SVG DOM getPointAtLength方法即可
SVGPoint getPointAtLength(in float distance)
例如
var point = document.getElementById("pathId").getPointAtLength(150);
OK, here is a possible solution to how to find the distance from the beginning of the path to any one of the points which were used to define it. The idea is to to create a temporary sub path of the original path for each of the points which make it up, and then use 'getToalLength()' to calculate the distance of this sub-path. This distance reflects the distance in the entire original path starting from the first point up to the current point. Now, after the distance has been calculated, it can be stored, and the temporary path can be removed. This way we can calculate and store the distance from the beginning of the original path to each of the points which make it up. Here is the code I use (a bit simplified to focus just on this goal):
var pointsAry = [["M",10,10],["T",30,50],["T",60,100],["T",80,200],["T",300,400]], subPath, path = []; for (var i = 0 ; i < pointsArray.length ; i++) { path.push(pointsAry[i]); subPath = paper.path(path).attr({ "stroke-opacity": 0 }); // make the path invisible pointsAry[i].subPathSum = subPath.getTotalLength(); subPath.remove(); }
paper
is created via Raphaeljs which also supplies thegetTotalLength()
function. Note the lines are created invisibly because their opacity is 0, and anyhow they are immediately removed.
相关问答
更多-
TCP/IP模型是一个________。[2023-05-19]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
SVG曲线文本内部路径(SVG curved text inside path)[2023-01-02]
您目前正在使用其中一个圈子路径作为文本的路径。 见下文。 path, circle { fill: transparent; stroke: black; }只需调用SVG DOM getPointAtLength方法即可 SVGPoint getPointAtLength(in float distance) 例如var point = document.getElementById("pathId").getPointAtLength(150); OK, here is a possible solution to how to find the distance from the beginning of the path to any one of th ... -
RaphaelJS如何让内联SVG在Firefox 3.6中运行?(How does RaphaelJS get inline SVG to work in Firefox 3.6?)[2024-01-12]
我将回答我自己的问题: Raphaël并没有真正做任何特别的事(在这种情况下)。 感谢我在RaphaëlGoogle小组上的帖子的答案, 我指出了正确的方向。 “内联SVG”意味着“内嵌常见HTML”(也在Mozilla博客文章中进行了解释),因此不使用XHTML和正确的命名空间。 我之前的理解是我只能通过 -
我如何为svg路径创建动画?(how do I animate a svg path?)[2023-10-22]
您可以为一个动画元素提供一个id,然后在第一次完成时执行.end以开始下一个。 这是一个例子 You can give an id to one animate element and then do .end to start the next when the first finishes. Here's an example