how to rename output of split command to match the first word in each line? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Community Moderator Election ResultsExtract data from a file and place in different files based on1 column valueHow to split a file by counting digit numbers within a row?Split string into array and print each element on a new line with commandlineHow to insert a line from file A above the FIRST LINE in file BSplitting a single file into multiple files based on matching strings in LinuxCompare two files and print only the first word of the lines which don't match along with a stringSplit single line into multiple lines, Newline character missing for all the lines in input filesplit file based on the first digit in the lineHow to print all the lines that's first word is the first word of a file?How to read a file line by line then take each line and insert into txt fileIterate print for each line in output
Road tyres vs "Street" tyres for charity ride on MTB Tandem
Simulating Exploding Dice
Why can't wing-mounted spoilers be used to steepen approaches?
Problems with Ubuntu mount /tmp
Didn't get enough time to take a Coding Test - what to do now?
Python - Fishing Simulator
How do you keep chess fun when your opponent constantly beats you?
Is this wall load bearing? Blueprints and photos attached
Working through the single responsibility principle (SRP) in Python when calls are expensive
What is this lever in Argentinian toilets?
How does ice melt when immersed in water?
Make it rain characters
Is above average number of years spent on PhD considered a red flag in future academia or industry positions?
how can a perfect fourth interval be considered either consonant or dissonant?
What force causes entropy to increase?
How to split my screen on my Macbook Air?
Typeface like Times New Roman but with "tied" percent sign
Match Roman Numerals
How are presidential pardons supposed to be used?
What are these Gizmos at Izaña Atmospheric Research Center in Spain?
Why does this iterative way of solving of equation work?
How did passengers keep warm on sail ships?
Can the DM override racial traits?
Did God make two great lights or did He make the great light two?
how to rename output of split command to match the first word in each line?
The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Community Moderator Election ResultsExtract data from a file and place in different files based on1 column valueHow to split a file by counting digit numbers within a row?Split string into array and print each element on a new line with commandlineHow to insert a line from file A above the FIRST LINE in file BSplitting a single file into multiple files based on matching strings in LinuxCompare two files and print only the first word of the lines which don't match along with a stringSplit single line into multiple lines, Newline character missing for all the lines in input filesplit file based on the first digit in the lineHow to print all the lines that's first word is the first word of a file?How to read a file line by line then take each line and insert into txt fileIterate print for each line in output
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have input.txt file (with 4 lines)like this:
GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1
How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
What I tried so far is this:
split -d -a 2 -l 1 input.txt output_
This is very far from the solution I need.
The solution per advice of @steeldriver is :
awk -F " " 'print >$1".txt"' input.txt
text-processing command-line split
add a comment |
I have input.txt file (with 4 lines)like this:
GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1
How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
What I tried so far is this:
split -d -a 2 -l 1 input.txt output_
This is very far from the solution I need.
The solution per advice of @steeldriver is :
awk -F " " 'print >$1".txt"' input.txt
text-processing command-line split
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday
add a comment |
I have input.txt file (with 4 lines)like this:
GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1
How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
What I tried so far is this:
split -d -a 2 -l 1 input.txt output_
This is very far from the solution I need.
The solution per advice of @steeldriver is :
awk -F " " 'print >$1".txt"' input.txt
text-processing command-line split
I have input.txt file (with 4 lines)like this:
GGTAACC_MIR4095P USP7 MKRN1 TSHZ3 EIF2C1 SRSF8 CAMK2G ARID4B
GCM_TINF2 MORF4L1 ABHD16A ZNF274 C7orf43 SNX33
chr9q34 MRPL41 OR5C1 LOC138159 GBGT1
REACTOME_SIGNALING_BY_NOTCH1 HDAC6 HDAC5 MAMLD1
How to split this file into 4 files (my original file has 39 lines) so that I get 4 files each named by the first word in a line:
GGTAACC_MIR4095P.txt
GCM_TINF2.txt
chr9q34.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
What I tried so far is this:
split -d -a 2 -l 1 input.txt output_
This is very far from the solution I need.
The solution per advice of @steeldriver is :
awk -F " " 'print >$1".txt"' input.txt
text-processing command-line split
text-processing command-line split
edited yesterday
anikaM
asked yesterday
anikaManikaM
13
13
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday
add a comment |
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday
add a comment |
2 Answers
2
active
oldest
votes
with Miller (https://github.com/johnkerl/miller) using
mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt
you will have this four files:
chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
add a comment |
Kindly use below command to achieve testes and worked fine
count=`wc -l filename| awk 'print $1'`
praveen@praveen:~$
praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
praveen@praveen:~$
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
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: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
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%2funix.stackexchange.com%2fquestions%2f512169%2fhow-to-rename-output-of-split-command-to-match-the-first-word-in-each-line%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
with Miller (https://github.com/johnkerl/miller) using
mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt
you will have this four files:
chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
add a comment |
with Miller (https://github.com/johnkerl/miller) using
mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt
you will have this four files:
chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
add a comment |
with Miller (https://github.com/johnkerl/miller) using
mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt
you will have this four files:
chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
with Miller (https://github.com/johnkerl/miller) using
mlr --nidx --ifs ' ' --repifs unsparsify then put -q 'tee > $1.".txt", $*' input.txt
you will have this four files:
chr9q34.txt
GCM_TINF2.txt
GGTAACC_MIR4095P.txt
REACTOME_SIGNALING_BY_NOTCH1.txt
answered yesterday
aborrusoaborruso
373311
373311
add a comment |
add a comment |
Kindly use below command to achieve testes and worked fine
count=`wc -l filename| awk 'print $1'`
praveen@praveen:~$
praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
praveen@praveen:~$
add a comment |
Kindly use below command to achieve testes and worked fine
count=`wc -l filename| awk 'print $1'`
praveen@praveen:~$
praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
praveen@praveen:~$
add a comment |
Kindly use below command to achieve testes and worked fine
count=`wc -l filename| awk 'print $1'`
praveen@praveen:~$
praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
praveen@praveen:~$
Kindly use below command to achieve testes and worked fine
count=`wc -l filename| awk 'print $1'`
praveen@praveen:~$
praveen@praveen:~$ for ((i=1;i<=$count;i++)); do j=`sed -n ''$i'p' filename`;awk -v i="$i" 'NR == i print $0' filename >$j.txt;done
praveen@praveen:~$
answered 20 hours ago
Praveen Kumar BSPraveen Kumar BS
1,7751311
1,7751311
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- 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%2funix.stackexchange.com%2fquestions%2f512169%2fhow-to-rename-output-of-split-command-to-match-the-first-word-in-each-line%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
-command-line, split, text-processing
Related: Extract data from a file and place in different files based on1 column value
– steeldriver
yesterday
Thank you so much!!! That indeed solved my problem, I will post the solution above.
– anikaM
yesterday