Skip to main content
added 168 characters in body
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

(although although that will result in an additional trailing space in the non-matching lines).lines; if that's undesirable, you could insert a space at the start of each File2 line and paste them without a delimiter

sed 's/^/ /; G' File2 | paste -d '' File1 -

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

(although that will result in an additional trailing space in the non-matching lines).

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

although that will result in an additional trailing space in the non-matching lines; if that's undesirable, you could insert a space at the start of each File2 line and paste them without a delimiter

sed 's/^/ /; G' File2 | paste -d '' File1 -
added 90 characters in body
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

(although that will result in an additional trailing space in the non-matching lines).

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -

(although that will result in an additional trailing space in the non-matching lines).

Post Undeleted by steeldriver
Post Deleted by steeldriver
Source Link
steeldriver
  • 83.9k
  • 12
  • 124
  • 175

You could read the lines of File2 into an indexed awk array, and then append them in turn to the corresponding lines of File

awk '
  NR==FNR {a[i++]=$0; next} 
  /^>/ {$0 = $0" "a[j++];}
  {print}
  ' File2 File1

Alternatively, if you have GNU sed (with the R extension) you could try

sed '/^>/ R File2' File1 | sed '/^>/ {N;s/\n/ /}'

If your File1 has exactly one additional line for every line that is to be matched, another option might be to double space File2 and then paste the files together

sed 'G' File2 | paste -d ' ' File1 -