Similar to
Append one column from fileB onto end of FileA and bash cut columns to one file and save onto the end of another file
However, in this case, I want the result to print to a file (file1.txt), not standard output (stdout).
Background // I have two tab-delimited files (both with 3 columns):
>file1.txt 4481679 4481722 . 4481791 4481820 . 4481947 4482268 . >file2.txt 13368 - 366 13668 + 940 14016 - 270 Desired output // I want to merge/append the second column of file2.txt to file1.txt (final file has 4 columns):
>file1.txt 4481679 4481722 . - 4481791 4481820 . + 4481947 4482268 . - Errors // So far, I have tried the following (which all look correct--like the above), but each simply prints to stdout:
Attempt1: $ paste file1.txt <(cut -f2 file2.txt) Attempt2: $ cut -f2 file2.txt | paste file1.txt - Attempt3: $ paste file1.txt <(awk '{print $2}' file2.txt) Also, the following prints "paste: write error: No space left on device paste: write error":
Attempt4: $ paste file1.txt <(cut -f2 file2.txt) >> file1.txt Attempt5: $ cut -f2 file2.txt | paste file1.txt - > file3.txt Any ideas how I can get this to work without using sponge from moreutils (i.e., using only things like paste, cut, awk, sed)?
没有评论:
发表评论