在bash中创建一个连接字符串和值的文件

在bash中创建一个连接字符串和值的文件,bash,loops,concatenation,readline,Bash,Loops,Concatenation,Readline,我需要创建一个包含许多行的FileToCreate.txt,其中包括数字数据值 从File1.txt FiletoCreate.txt: File1.txt: v1 v2 v3 168 361 20 169 366 22 . . . Vn1 Vn2 Vn3 到目前为止,我试过: ifile=file.txt st='ncap2 -Oh -s 'TOPOBATHY(' st1=')=' st2='.'' line_no=$(wc -l < $ifile) f

我需要创建一个包含许多行的FileToCreate.txt,其中包括数字数据值

从File1.txt

FiletoCreate.txt: File1.txt:

v1  v2 v3

168 361 20

169 366 22

.    .   .

Vn1 Vn2  Vn3
到目前为止,我试过:

ifile=file.txt

st='ncap2 -Oh -s 'TOPOBATHY('

st1=')='

st2='.''

line_no=$(wc -l < $ifile)

for row in 'seq 1 $line_no'; do


cat $ifile | awk -v st=$st -v st1=$st1 -v st2=$st2 


'{if (NR==$row) print(st $1 "," $2 st1 $3 st2 st3)}' >> $tmpdir/tmp
ifile=file.txt
st='ncap2-Oh-s'TOPOBATHY'
st1=')='
st2='.'
行号=$(wc-l<$ifile)
对于“序号1$行”中的行;做
类别$ifile | awk-VST=$st-VST1=$st1-VST2=$st2
“{if(NR==$row)打印(st$1)”,“$2 st1$3 st2 st3”)>>tmpdir/tmp
这是我最早的剧本之一,它非常做作,不起作用。请某人

你能指引我吗

提前感谢,,
Nella

尝试查看以下脚本作品:

#!/bin/bash

while read val1 val2 val3
do
  echo "ncap2 -Oh -s'TOPOBATHY($val1,$val2)=$val3.'"
done < file1.txt > FiletoCreate.txt
#/bin/bash
而读val1 val2 val3
做
echo“ncap2-Oh-s'TOPOBATHY($val1,$val2)=$val3.”
完成FiletoCreate.txt
while
循环逐行读取输入
file1.txt
并将3个值存储在val1、val2和val3中(假设这些值是空格分隔的)

while
的每次迭代过程中,
echo
使用字符串打印值

整个
while
输出被重定向到
FiletoCreate.txt

#!/bin/bash

while read val1 val2 val3
do
  echo "ncap2 -Oh -s'TOPOBATHY($val1,$val2)=$val3.'"
done < file1.txt > FiletoCreate.txt