批处理之家's Archiver

netdzb 发表于 2020-8-31 09:53

shell偶数行首增加字符的问题

[i=s] 本帖最后由 netdzb 于 2020-8-31 10:37 编辑 [/i]

#!/bin/bash
NUM=0
while read LINE
do
        NUM=$NUM+1
        if [ $((NUM%2)) == 0 ] ; then
                sed /$LINE/ 's/^/#&/'
        fi
done < 01.txt

我想在行首增加#,代码运行报错。

Batcher 发表于 2020-8-31 11:37

[b]回复 [url=http://bbs.bathome.net/redirect.php?goto=findpost&pid=231990&ptid=56642]1#[/url] [i]netdzb[/i] [/b][code]sed '0~2s/^/#/' 01.txt[/code]

页: [1]

Powered by Discuz! Archiver 7.2  © 2001-2009 Comsenz Inc.