首页 \ 问答 \ 读取行时,awk $行有多个分隔符(While read line, awk $line with multiple delimiters)

读取行时,awk $行有多个分隔符(While read line, awk $line with multiple delimiters)

我正在尝试这个的一个小变体,除了我告诉awk基于第5个字段要拆分的文件的分隔符可以是冒号“:”或制表符\ t。 我单独执行awk -F '[:\t]'部分,它确实打印了正确的$ 5字段。

但是,当我尝试将其合并到更大的命令时,它返回以下错误:

                                                             print > f
awk: cmd. line:9:                                            ^ syntax error

这是代码:

awk -F '[:\t]' '    # read the list of numbers in Tile_Number_List
    FNR == NR {
        num[$1]
        next
    }

    # process each line of the .BAM file
    # any lines with an "unknown" $5 will be ignored
    $5 in num {
        f = "Alignments_" $5 ".sam"        print > f
    } ' Tile_Number_List.txt little.sam

为什么不能使用-F选项?


I am trying a small variation of this, except I telling awk that the delimiter of the file to be split based on the 5th field can either be a colon ":" or a tab \t. I do the awk -F '[:\t]' part alone, it does indeed print the right $5 field.

However, when I try to incorporate this into the bigger command, it returns the following error:

                                                             print > f
awk: cmd. line:9:                                            ^ syntax error

This is the code:

awk -F '[:\t]' '    # read the list of numbers in Tile_Number_List
    FNR == NR {
        num[$1]
        next
    }

    # process each line of the .BAM file
    # any lines with an "unknown" $5 will be ignored
    $5 in num {
        f = "Alignments_" $5 ".sam"        print > f
    } ' Tile_Number_List.txt little.sam

Why won't it work with the -F option?


原文:https://stackoverflow.com/questions/16404666
更新时间:2022-06-26 20:06

最满意答案

使用以下使用rzSlider的实现解决: https ://jsfiddle.net/ValentinH/954eve2L/

<h2>Range slider</h2>
Min Value:
<input type="number" ng-model="minRangeSlider.minValue" />
<br/>Max Value:
<input type="number" ng-model="minRangeSlider.maxValue" />
<br/>
<rzslider rz-slider-model="minRangeSlider.minValue" rz-slider-high="minRangeSlider.maxValue" rz-slider-options="minRangeSlider.options"></rzslider>

Resolved using the following implementation that use rzSlider: https://jsfiddle.net/ValentinH/954eve2L/

<h2>Range slider</h2>
Min Value:
<input type="number" ng-model="minRangeSlider.minValue" />
<br/>Max Value:
<input type="number" ng-model="minRangeSlider.maxValue" />
<br/>
<rzslider rz-slider-model="minRangeSlider.minValue" rz-slider-high="minRangeSlider.maxValue" rz-slider-options="minRangeSlider.options"></rzslider>

相关问答

更多
  • 理想情况下,这将通过像Angular这样的数据绑定库来处理,但是您可以在加载时进行计算,并在每个滑块的slide方法中进行计算,如下所示: HTML更改:

    To pay monthly (interest rate included):

    Total amount to pay all mon ...

  • 将您的值选项替换为创建事件: create: function () { $(this).slider( "option", "value", $(this).next().val() ); }, jsFiddle例子 Replace your value option with the create event: create: function () { $(this).slider( "option", "value", $(this).next().val() ); }, jsF ...
  • 您可以按照以下说明执行此操作: ngOnInit() { jQuery(this.elementRef.nativeElement).find("#slider").slider({ (...) slide: ( event, ui ) => { this.slideValue = ui.value; } } } 请注意,使用箭头函数可以在组件属性slideValue设置值。 编辑 您可以将滑块包装到符合ngModel的组件中。 这是一 ...
  • ng-init=0不会设置任何范围属性。 ng-init需要一个Angular表达式,它根据作用域进行评估。 您可以编写ng-init='value1 = 0'但最好在控制器中初始化模型值: $scope.value1 = 0; value = 0不应与Angular表单元素一起使用( type=radio除外)。 这是一个最小的小提琴 ,只包括Angular,只显示我上面谈到的变化。 ng-init=0 won't set any scope properties. ng-init expects an ...
  • 变化: $( "#revAttain > span" ).each(function() { var value = parseInt( $( this ).text(), 10 ); $( this ).empty().slider({ value: value, range:"min", orientation: "horizontal", animate: true, slide: function(event, ui) { $ ...
  • 使用以下使用rzSlider的实现解决: https ://jsfiddle.net/ValentinH/954eve2L/

    Range slider

    Min Value:
    Max Value:
  • 由于缺乏对表单中输入结构的更好理解,我将假设表单中唯一的隐藏字段与每个滑块匹配,因此可以对它们进行索引。 因此,在each循环中实现插件更容易,因此您可以在javscript闭包内轻松访问集合的每个元素。 jQuery UI可以让您访问事件中的各个元素,但并非所有插件都可以这样做,因此这种模式有时会非常有用。 var $sliders=$("#slider1,#slider2,#slider3,#slider4,#slider5") $sliders.each(function(){ /* now ...
  • 使用以下行访问滑块的当前值: var val = $('#slider').slider("option", "value"); Use the following line to access the current values of the slider: var val = $('#slider').slider("option", "value");
  • 1)在一个页面中使用一个DOM ID; 2)如果你想使用重复的类; 3)使用找到子元素的.find()或.find() 。 喜欢这个: var $this = $(this); var amount = $this.find(".amount"); var slider = $this.find(".slider-range") .slider({ range: true, min: 18, max: 100, values: [21, 30], ...
  • 您可以设置隐藏的表单字段,以便在更改时保存滑块的值。 然后,当您的表单重新加载时,根据隐藏的表单字段设置滑块。 我通常用滑块做的是在它们下面直接有一个文本框,当用户设置滑块时它会更新。 通过一些一致的命名约定,这很容易做到。 这是一个简单的例子: