0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[AWK] 特定の文字のあとにテキストを挿入する

Posted at

特定の文字のあとにファイルにある任意のテキストを挿入します.

# テストファイルを作製します
## infileのINSERT部分にinsertファイルにある文字を挿入します
cat << EOF>infile
A
B
INSERT
C
D
EOF

cat << EOF >insert
aaaaa
bbbbb
EOF
cat infile |
  awk '1;/INSERT/{
    while((getline line < "insert")>0){
      print line
   }}' |
  grep -v "INSERT"

# 出力
A
B
aaaaa
bbbbb
C
D
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?