Extract each line and append it to another file from one of the columnsHow can I shuffle the lines of a text file on the Unix command line or in a shell script?AWK: Access captured group from line patternUsing awk to print all columns from the nth to the lastawk file manipulationBash tool to get nth line from a filematch lines where a specified column range does not contain the dot characterPrinting the last column of a line in a fileextracting data from a column based on another columnextracting lines from a multi-column fileextracting lines with pivot column
Launch capabilities of GSLV Mark III
Can you take actions after being healed at 0hp?
Which genus do I use for neutral expressions in German?
Why do dragons like shiny stuff?
Not been paid even after reminding the Treasurer; what should I do?
Could an areostationary satellite help locate asteroids?
Why does putting a dot after the URL remove login information?
If a vampire drinks blood of a sick human, does the vampire get infected?
Ancients don't give a full level?
`printf` improvement with C++ variadic templates
Can attackers change the public key of certificate during the SSL handshake
How to deploy a LSTM Model
How easy is it to get a gun illegally in the United States?
VHDL optimization
…down the primrose path
I was contacted by a private bank overseas to get my inheritance
Description of past perfect tense
Why does capacitance not depend on the material of the plates?
Did silent film actors actually say their lines or did they simply improvise “dialogue” while being filmed?
Why did the US Airways Flight 1549 passengers stay on the wings?
Is space radiation a risk for space film photography, and how is this prevented?
Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?
How can I use commands with sudo without changing owner of the files?
FORMATDATE and format pattern to add year when using format pattern "M"
Extract each line and append it to another file from one of the columns
How can I shuffle the lines of a text file on the Unix command line or in a shell script?AWK: Access captured group from line patternUsing awk to print all columns from the nth to the lastawk file manipulationBash tool to get nth line from a filematch lines where a specified column range does not contain the dot characterPrinting the last column of a line in a fileextracting data from a column based on another columnextracting lines from a multi-column fileextracting lines with pivot column
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
How is it possible to extract each line from the below file and append the content to a file which is named after 3rd column (e.g. Backbone_3710)?
HWI-ST945_0069:2:1101:17889:2254#GNNNNN/11 16 Backbone_3710 13730 1 28M1D61M1D11M * 0 0 AATAGGGAAAAGCCGGCTATCGGAATCGAACCGATGACCATCGCATTACAAATGCGATGCTCTAACCTCTGAGCTAAGCGGGCCCACATAACAGAAATCT * NM:i:5 ms:i:144 AS:i:148 nn:i:0 tp:A:P cm:i:5 s1:i:40 s2:i:59 de:f:0.0490 rl:i:0
HWI-ST945_0069:2:1101:17753:2257#GNNNNN/11 16 Backbone_2546 1217877 23 23S62M1I14M * 0 0 ATTTGATTGTGCATATTAGTGTGTTTTTTCATTTGTGCATGCATGGCAAGTCATAAAAAATACAAAAGAACTACATAAGCATTTAGGGTTTAATTTCACA * NM:i:3 ms:i:118 AS:i:118 nn:i:0 tp:A:P cm:i:3 s1:i:51 s2:i:0 de:f:0.0390 rl:i:0
HWI-ST945_0069:2:1101:17922:2282#ANNNNN/11 16 Backbone_2065 955626 2 16S20M2I7M1D11M3I35M1D6M * 0 0 GAACGAGAAGAAGATTATTTCAACGTCGAGGCTTGGAAAAACTTTATTTAGGAGCTTCAAATTGATAGGGCAGTCCTACGAGTGGAATAAGAGGACATGT * NM:i:9 ms:i:78 AS:i:80 nn:i:0 tp:A:P cm:i:4 s1:i:27 s2:i:0 de:f:0.0723 rl:i:0
HWI-ST945_0069:2:1101:17799:2282#ANNNNN/11 16 Backbone_3859 11630 1 75M1I24M * 0 0 TCGTGTTCAACACAGTATTCATACGGGAAATTATGATCAAAGAGTTCTTTATCAACCGCCATCTACTTCAGAGATCCCTACGGAAATCTTTTTCAAATAC * NM:i:5 ms:i:144 AS:i:144 nn:i:0 tp:A:P cm:i:5 s1:i:47 s2:i:54 de:f:0.0500 rl:i:0
HWI-ST945_0069:2:1101:17876:2290#GNNNNN/11 0 Backbone_1630 114655 2 23S37M40S * 0 0 ACATGCATAAGGAATCTTTGGCCTAGTCTCAAAAGTCGGTCTAATTCAGAAGTACTAATTCAAGAGATAGAATATGAGGATGAACAAGAGTATGATAAGG * NM:i:1 ms:i:64 AS:i:64 nn:i:0 tp:A:P cm:i:3 s1:i:27 s2:i:0 de:f:0.0270 rl:i:0
HWI-ST945_0069:2:1101:17982:2293#GNNNNN/11 4 * 0 0 * * 0 0 TGATTAAAATAATTGCTCATAAATATAATAGAATTAAAGGAAAAAGGTAAAAGAAAGCATTGAAGAAAAGAAAGAAAGAGCCAAGTTTTATATGCAGTAG * rl:i:0
HWI-ST945_0069:2:1101:17833:2296#GNNNNN/11 4 * 0 0 * * 0 0 TGAGGGTTCCAGATTAAATGCCAATTCAAACTTCCTACTGGGAATCATTGTTCAGGCGAGTTCTGACAACTCTTAGTGGAGAAGGCATTGGTGCCTACCC * rl:i:0
HWI-ST945_0069:2:1101:17908:2302#GNNNNN/11 4 * 0 0 * * 0 0 TAATTTAAATAGTGCATTGGACTTTCAGATTTGGTTCAATATTCAACATGGGTCGACTTCTTATGGATGATTTTAGAAGTGGGTTTGAGGAAGGACCTTG * rl:i:0
HWI-ST945_0069:2:1101:17759:2305#ANNNNN/11 16 Backbone_870 367318 10 27M1I34M3D6M1I31M * 0 0 ACATAGGGCCTCCATTCCCTAGTCGCCTTTTTGGAACATTAGGGCTCCAATCCCAGAGTTGAGTTTAATAGATAGGGCCTCCATTCCCTAGTCGCCTTTT * NM:i:13 ms:i:78 AS:i:78 nn:i:0 tp:A:P cm:i:3 s1:i:43 s2:i:42 de:f:0.1089 rl:i:0
HWI-ST945_0069:2:1101:17878:2318#GNNNNN/11 0 Backbone_2304 815440 1 67M1D27M6S * 0 0 TGGGTTCTTTTATTAAAGACCCTATATGCTTTACTACGTGAGGAATATCCAATGAAAATACCTTCATCCGACTTAGCATCAAATTTACCCAATTAGTCTT * NM:i:3 ms:i:160 AS:i:160 nn:i:0 tp:A:P cm:i:7 s1:i:60 s2:i:71 de:f:0.0316 rl:i:0
Thank you in advance.
awk
|
show 1 more comment
How is it possible to extract each line from the below file and append the content to a file which is named after 3rd column (e.g. Backbone_3710)?
HWI-ST945_0069:2:1101:17889:2254#GNNNNN/11 16 Backbone_3710 13730 1 28M1D61M1D11M * 0 0 AATAGGGAAAAGCCGGCTATCGGAATCGAACCGATGACCATCGCATTACAAATGCGATGCTCTAACCTCTGAGCTAAGCGGGCCCACATAACAGAAATCT * NM:i:5 ms:i:144 AS:i:148 nn:i:0 tp:A:P cm:i:5 s1:i:40 s2:i:59 de:f:0.0490 rl:i:0
HWI-ST945_0069:2:1101:17753:2257#GNNNNN/11 16 Backbone_2546 1217877 23 23S62M1I14M * 0 0 ATTTGATTGTGCATATTAGTGTGTTTTTTCATTTGTGCATGCATGGCAAGTCATAAAAAATACAAAAGAACTACATAAGCATTTAGGGTTTAATTTCACA * NM:i:3 ms:i:118 AS:i:118 nn:i:0 tp:A:P cm:i:3 s1:i:51 s2:i:0 de:f:0.0390 rl:i:0
HWI-ST945_0069:2:1101:17922:2282#ANNNNN/11 16 Backbone_2065 955626 2 16S20M2I7M1D11M3I35M1D6M * 0 0 GAACGAGAAGAAGATTATTTCAACGTCGAGGCTTGGAAAAACTTTATTTAGGAGCTTCAAATTGATAGGGCAGTCCTACGAGTGGAATAAGAGGACATGT * NM:i:9 ms:i:78 AS:i:80 nn:i:0 tp:A:P cm:i:4 s1:i:27 s2:i:0 de:f:0.0723 rl:i:0
HWI-ST945_0069:2:1101:17799:2282#ANNNNN/11 16 Backbone_3859 11630 1 75M1I24M * 0 0 TCGTGTTCAACACAGTATTCATACGGGAAATTATGATCAAAGAGTTCTTTATCAACCGCCATCTACTTCAGAGATCCCTACGGAAATCTTTTTCAAATAC * NM:i:5 ms:i:144 AS:i:144 nn:i:0 tp:A:P cm:i:5 s1:i:47 s2:i:54 de:f:0.0500 rl:i:0
HWI-ST945_0069:2:1101:17876:2290#GNNNNN/11 0 Backbone_1630 114655 2 23S37M40S * 0 0 ACATGCATAAGGAATCTTTGGCCTAGTCTCAAAAGTCGGTCTAATTCAGAAGTACTAATTCAAGAGATAGAATATGAGGATGAACAAGAGTATGATAAGG * NM:i:1 ms:i:64 AS:i:64 nn:i:0 tp:A:P cm:i:3 s1:i:27 s2:i:0 de:f:0.0270 rl:i:0
HWI-ST945_0069:2:1101:17982:2293#GNNNNN/11 4 * 0 0 * * 0 0 TGATTAAAATAATTGCTCATAAATATAATAGAATTAAAGGAAAAAGGTAAAAGAAAGCATTGAAGAAAAGAAAGAAAGAGCCAAGTTTTATATGCAGTAG * rl:i:0
HWI-ST945_0069:2:1101:17833:2296#GNNNNN/11 4 * 0 0 * * 0 0 TGAGGGTTCCAGATTAAATGCCAATTCAAACTTCCTACTGGGAATCATTGTTCAGGCGAGTTCTGACAACTCTTAGTGGAGAAGGCATTGGTGCCTACCC * rl:i:0
HWI-ST945_0069:2:1101:17908:2302#GNNNNN/11 4 * 0 0 * * 0 0 TAATTTAAATAGTGCATTGGACTTTCAGATTTGGTTCAATATTCAACATGGGTCGACTTCTTATGGATGATTTTAGAAGTGGGTTTGAGGAAGGACCTTG * rl:i:0
HWI-ST945_0069:2:1101:17759:2305#ANNNNN/11 16 Backbone_870 367318 10 27M1I34M3D6M1I31M * 0 0 ACATAGGGCCTCCATTCCCTAGTCGCCTTTTTGGAACATTAGGGCTCCAATCCCAGAGTTGAGTTTAATAGATAGGGCCTCCATTCCCTAGTCGCCTTTT * NM:i:13 ms:i:78 AS:i:78 nn:i:0 tp:A:P cm:i:3 s1:i:43 s2:i:42 de:f:0.1089 rl:i:0
HWI-ST945_0069:2:1101:17878:2318#GNNNNN/11 0 Backbone_2304 815440 1 67M1D27M6S * 0 0 TGGGTTCTTTTATTAAAGACCCTATATGCTTTACTACGTGAGGAATATCCAATGAAAATACCTTCATCCGACTTAGCATCAAATTTACCCAATTAGTCTT * NM:i:3 ms:i:160 AS:i:160 nn:i:0 tp:A:P cm:i:7 s1:i:60 s2:i:71 de:f:0.0316 rl:i:0
Thank you in advance.
awk
You want a file named*?
– Shawn
Mar 27 at 3:41
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
1
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having thebashtag in this. So removed that alone!
– Inian
Mar 27 at 4:18
|
show 1 more comment
How is it possible to extract each line from the below file and append the content to a file which is named after 3rd column (e.g. Backbone_3710)?
HWI-ST945_0069:2:1101:17889:2254#GNNNNN/11 16 Backbone_3710 13730 1 28M1D61M1D11M * 0 0 AATAGGGAAAAGCCGGCTATCGGAATCGAACCGATGACCATCGCATTACAAATGCGATGCTCTAACCTCTGAGCTAAGCGGGCCCACATAACAGAAATCT * NM:i:5 ms:i:144 AS:i:148 nn:i:0 tp:A:P cm:i:5 s1:i:40 s2:i:59 de:f:0.0490 rl:i:0
HWI-ST945_0069:2:1101:17753:2257#GNNNNN/11 16 Backbone_2546 1217877 23 23S62M1I14M * 0 0 ATTTGATTGTGCATATTAGTGTGTTTTTTCATTTGTGCATGCATGGCAAGTCATAAAAAATACAAAAGAACTACATAAGCATTTAGGGTTTAATTTCACA * NM:i:3 ms:i:118 AS:i:118 nn:i:0 tp:A:P cm:i:3 s1:i:51 s2:i:0 de:f:0.0390 rl:i:0
HWI-ST945_0069:2:1101:17922:2282#ANNNNN/11 16 Backbone_2065 955626 2 16S20M2I7M1D11M3I35M1D6M * 0 0 GAACGAGAAGAAGATTATTTCAACGTCGAGGCTTGGAAAAACTTTATTTAGGAGCTTCAAATTGATAGGGCAGTCCTACGAGTGGAATAAGAGGACATGT * NM:i:9 ms:i:78 AS:i:80 nn:i:0 tp:A:P cm:i:4 s1:i:27 s2:i:0 de:f:0.0723 rl:i:0
HWI-ST945_0069:2:1101:17799:2282#ANNNNN/11 16 Backbone_3859 11630 1 75M1I24M * 0 0 TCGTGTTCAACACAGTATTCATACGGGAAATTATGATCAAAGAGTTCTTTATCAACCGCCATCTACTTCAGAGATCCCTACGGAAATCTTTTTCAAATAC * NM:i:5 ms:i:144 AS:i:144 nn:i:0 tp:A:P cm:i:5 s1:i:47 s2:i:54 de:f:0.0500 rl:i:0
HWI-ST945_0069:2:1101:17876:2290#GNNNNN/11 0 Backbone_1630 114655 2 23S37M40S * 0 0 ACATGCATAAGGAATCTTTGGCCTAGTCTCAAAAGTCGGTCTAATTCAGAAGTACTAATTCAAGAGATAGAATATGAGGATGAACAAGAGTATGATAAGG * NM:i:1 ms:i:64 AS:i:64 nn:i:0 tp:A:P cm:i:3 s1:i:27 s2:i:0 de:f:0.0270 rl:i:0
HWI-ST945_0069:2:1101:17982:2293#GNNNNN/11 4 * 0 0 * * 0 0 TGATTAAAATAATTGCTCATAAATATAATAGAATTAAAGGAAAAAGGTAAAAGAAAGCATTGAAGAAAAGAAAGAAAGAGCCAAGTTTTATATGCAGTAG * rl:i:0
HWI-ST945_0069:2:1101:17833:2296#GNNNNN/11 4 * 0 0 * * 0 0 TGAGGGTTCCAGATTAAATGCCAATTCAAACTTCCTACTGGGAATCATTGTTCAGGCGAGTTCTGACAACTCTTAGTGGAGAAGGCATTGGTGCCTACCC * rl:i:0
HWI-ST945_0069:2:1101:17908:2302#GNNNNN/11 4 * 0 0 * * 0 0 TAATTTAAATAGTGCATTGGACTTTCAGATTTGGTTCAATATTCAACATGGGTCGACTTCTTATGGATGATTTTAGAAGTGGGTTTGAGGAAGGACCTTG * rl:i:0
HWI-ST945_0069:2:1101:17759:2305#ANNNNN/11 16 Backbone_870 367318 10 27M1I34M3D6M1I31M * 0 0 ACATAGGGCCTCCATTCCCTAGTCGCCTTTTTGGAACATTAGGGCTCCAATCCCAGAGTTGAGTTTAATAGATAGGGCCTCCATTCCCTAGTCGCCTTTT * NM:i:13 ms:i:78 AS:i:78 nn:i:0 tp:A:P cm:i:3 s1:i:43 s2:i:42 de:f:0.1089 rl:i:0
HWI-ST945_0069:2:1101:17878:2318#GNNNNN/11 0 Backbone_2304 815440 1 67M1D27M6S * 0 0 TGGGTTCTTTTATTAAAGACCCTATATGCTTTACTACGTGAGGAATATCCAATGAAAATACCTTCATCCGACTTAGCATCAAATTTACCCAATTAGTCTT * NM:i:3 ms:i:160 AS:i:160 nn:i:0 tp:A:P cm:i:7 s1:i:60 s2:i:71 de:f:0.0316 rl:i:0
Thank you in advance.
awk
How is it possible to extract each line from the below file and append the content to a file which is named after 3rd column (e.g. Backbone_3710)?
HWI-ST945_0069:2:1101:17889:2254#GNNNNN/11 16 Backbone_3710 13730 1 28M1D61M1D11M * 0 0 AATAGGGAAAAGCCGGCTATCGGAATCGAACCGATGACCATCGCATTACAAATGCGATGCTCTAACCTCTGAGCTAAGCGGGCCCACATAACAGAAATCT * NM:i:5 ms:i:144 AS:i:148 nn:i:0 tp:A:P cm:i:5 s1:i:40 s2:i:59 de:f:0.0490 rl:i:0
HWI-ST945_0069:2:1101:17753:2257#GNNNNN/11 16 Backbone_2546 1217877 23 23S62M1I14M * 0 0 ATTTGATTGTGCATATTAGTGTGTTTTTTCATTTGTGCATGCATGGCAAGTCATAAAAAATACAAAAGAACTACATAAGCATTTAGGGTTTAATTTCACA * NM:i:3 ms:i:118 AS:i:118 nn:i:0 tp:A:P cm:i:3 s1:i:51 s2:i:0 de:f:0.0390 rl:i:0
HWI-ST945_0069:2:1101:17922:2282#ANNNNN/11 16 Backbone_2065 955626 2 16S20M2I7M1D11M3I35M1D6M * 0 0 GAACGAGAAGAAGATTATTTCAACGTCGAGGCTTGGAAAAACTTTATTTAGGAGCTTCAAATTGATAGGGCAGTCCTACGAGTGGAATAAGAGGACATGT * NM:i:9 ms:i:78 AS:i:80 nn:i:0 tp:A:P cm:i:4 s1:i:27 s2:i:0 de:f:0.0723 rl:i:0
HWI-ST945_0069:2:1101:17799:2282#ANNNNN/11 16 Backbone_3859 11630 1 75M1I24M * 0 0 TCGTGTTCAACACAGTATTCATACGGGAAATTATGATCAAAGAGTTCTTTATCAACCGCCATCTACTTCAGAGATCCCTACGGAAATCTTTTTCAAATAC * NM:i:5 ms:i:144 AS:i:144 nn:i:0 tp:A:P cm:i:5 s1:i:47 s2:i:54 de:f:0.0500 rl:i:0
HWI-ST945_0069:2:1101:17876:2290#GNNNNN/11 0 Backbone_1630 114655 2 23S37M40S * 0 0 ACATGCATAAGGAATCTTTGGCCTAGTCTCAAAAGTCGGTCTAATTCAGAAGTACTAATTCAAGAGATAGAATATGAGGATGAACAAGAGTATGATAAGG * NM:i:1 ms:i:64 AS:i:64 nn:i:0 tp:A:P cm:i:3 s1:i:27 s2:i:0 de:f:0.0270 rl:i:0
HWI-ST945_0069:2:1101:17982:2293#GNNNNN/11 4 * 0 0 * * 0 0 TGATTAAAATAATTGCTCATAAATATAATAGAATTAAAGGAAAAAGGTAAAAGAAAGCATTGAAGAAAAGAAAGAAAGAGCCAAGTTTTATATGCAGTAG * rl:i:0
HWI-ST945_0069:2:1101:17833:2296#GNNNNN/11 4 * 0 0 * * 0 0 TGAGGGTTCCAGATTAAATGCCAATTCAAACTTCCTACTGGGAATCATTGTTCAGGCGAGTTCTGACAACTCTTAGTGGAGAAGGCATTGGTGCCTACCC * rl:i:0
HWI-ST945_0069:2:1101:17908:2302#GNNNNN/11 4 * 0 0 * * 0 0 TAATTTAAATAGTGCATTGGACTTTCAGATTTGGTTCAATATTCAACATGGGTCGACTTCTTATGGATGATTTTAGAAGTGGGTTTGAGGAAGGACCTTG * rl:i:0
HWI-ST945_0069:2:1101:17759:2305#ANNNNN/11 16 Backbone_870 367318 10 27M1I34M3D6M1I31M * 0 0 ACATAGGGCCTCCATTCCCTAGTCGCCTTTTTGGAACATTAGGGCTCCAATCCCAGAGTTGAGTTTAATAGATAGGGCCTCCATTCCCTAGTCGCCTTTT * NM:i:13 ms:i:78 AS:i:78 nn:i:0 tp:A:P cm:i:3 s1:i:43 s2:i:42 de:f:0.1089 rl:i:0
HWI-ST945_0069:2:1101:17878:2318#GNNNNN/11 0 Backbone_2304 815440 1 67M1D27M6S * 0 0 TGGGTTCTTTTATTAAAGACCCTATATGCTTTACTACGTGAGGAATATCCAATGAAAATACCTTCATCCGACTTAGCATCAAATTTACCCAATTAGTCTT * NM:i:3 ms:i:160 AS:i:160 nn:i:0 tp:A:P cm:i:7 s1:i:60 s2:i:71 de:f:0.0316 rl:i:0
Thank you in advance.
awk
awk
edited Mar 27 at 4:16
ghoti
36.7k7 gold badges46 silver badges89 bronze badges
36.7k7 gold badges46 silver badges89 bronze badges
asked Mar 27 at 3:38
user977828user977828
2,0777 gold badges37 silver badges72 bronze badges
2,0777 gold badges37 silver badges72 bronze badges
You want a file named*?
– Shawn
Mar 27 at 3:41
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
1
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having thebashtag in this. So removed that alone!
– Inian
Mar 27 at 4:18
|
show 1 more comment
You want a file named*?
– Shawn
Mar 27 at 3:41
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
1
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having thebashtag in this. So removed that alone!
– Inian
Mar 27 at 4:18
You want a file named
*?– Shawn
Mar 27 at 3:41
You want a file named
*?– Shawn
Mar 27 at 3:41
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
1
1
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having the
bash tag in this. So removed that alone!– Inian
Mar 27 at 4:18
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having the
bash tag in this. So removed that alone!– Inian
Mar 27 at 4:18
|
show 1 more comment
1 Answer
1
active
oldest
votes
Something like
awk '$3 != "*" print $0 >> $3; close($3) ' input.txt
should work. Note the use of close() after every print to avoid running out of file descriptors if there's going to be a bunch of different output files.
1
This would be good if there are no duplicate$3entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something likeawk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file
– Inian
Mar 27 at 4:45
@Inian there's no point to thatENDblock because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out theclose()is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.
– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369424%2fextract-each-line-and-append-it-to-another-file-from-one-of-the-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Something like
awk '$3 != "*" print $0 >> $3; close($3) ' input.txt
should work. Note the use of close() after every print to avoid running out of file descriptors if there's going to be a bunch of different output files.
1
This would be good if there are no duplicate$3entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something likeawk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file
– Inian
Mar 27 at 4:45
@Inian there's no point to thatENDblock because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out theclose()is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.
– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
add a comment |
Something like
awk '$3 != "*" print $0 >> $3; close($3) ' input.txt
should work. Note the use of close() after every print to avoid running out of file descriptors if there's going to be a bunch of different output files.
1
This would be good if there are no duplicate$3entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something likeawk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file
– Inian
Mar 27 at 4:45
@Inian there's no point to thatENDblock because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out theclose()is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.
– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
add a comment |
Something like
awk '$3 != "*" print $0 >> $3; close($3) ' input.txt
should work. Note the use of close() after every print to avoid running out of file descriptors if there's going to be a bunch of different output files.
Something like
awk '$3 != "*" print $0 >> $3; close($3) ' input.txt
should work. Note the use of close() after every print to avoid running out of file descriptors if there's going to be a bunch of different output files.
answered Mar 27 at 4:22
ShawnShawn
8,5472 gold badges7 silver badges16 bronze badges
8,5472 gold badges7 silver badges16 bronze badges
1
This would be good if there are no duplicate$3entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something likeawk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file
– Inian
Mar 27 at 4:45
@Inian there's no point to thatENDblock because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out theclose()is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.
– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
add a comment |
1
This would be good if there are no duplicate$3entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something likeawk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file
– Inian
Mar 27 at 4:45
@Inian there's no point to thatENDblock because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out theclose()is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.
– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
1
1
This would be good if there are no duplicate
$3 entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something like awk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file– Inian
Mar 27 at 4:45
This would be good if there are no duplicate
$3 entries present. If they are present, it would mean opening and closing the file handles for each duplicate entry. The ideal way would be store them and close them all at the end, something like awk ' $3 !~ "*" fh[$3]; print $0 >> $3 END for (handle in fh) close(handle) ' file– Inian
Mar 27 at 4:45
@Inian there's no point to that
END block because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out the close() is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.– Shawn
Mar 27 at 4:54
@Inian there's no point to that
END block because all open files are closed at exit anyways. If OP's data is only going to have up to a few dozen different files written to, leaving out the close() is likely fine. Hundreds or thousands? Then you have problems with the limit on open files, and need a way to prune them. This is the easy way.– Shawn
Mar 27 at 4:54
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
They could be 2000 to 10.000 files.
– user977828
Mar 27 at 5:21
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55369424%2fextract-each-line-and-append-it-to-another-file-from-one-of-the-columns%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You want a file named
*?– Shawn
Mar 27 at 3:41
Good point. If it is a star then to ignore the line.
– user977828
Mar 27 at 3:53
1
@user977828: Post the efforts that you made yourself to solve this
– Inian
Mar 27 at 4:02
@Inian, you changed the tag from bash to awk, but I don't see any of either language in the question. What did I miss?
– ghoti
Mar 27 at 4:17
@ghoti: It was tagged with both of them from the OP. I didn't see any relevance for having the
bashtag in this. So removed that alone!– Inian
Mar 27 at 4:18