Sorting and editing a text file to output a new filesum pair of columns based on matching fieldsPrint top 5%...
Distinguish the explanations of Galadriel's test in LotR
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
Is it okay to roll multiple attacks that all have advantage in one cluster?
What is the parallel of Day of the Dead with Stranger things?
Given a 32 bit number, what is an efficient way to scale each byte by a certain factor?
LED glows slightly during soldering
How to design a CMC (Common Mode Choke) footprint to allow no-pop solution
The three greedy pirates
In Spider-Man: Far From Home, is this superhero name a reference to another comic book?
When did "&" stop being taught alongside the alphabet?
Matrix with arrows and comments
Should I include code in my research paper?
Chorophyll and photosynthesis in plants with coloured leaves
Is there a nice way to implement a conditional type with default fail case?
Is there a strong legal guarantee that the U.S. can give to another country that it won't attack them?
Why did Old English lose both thorn and eth?
How to know if blackberries are safe to eat
What is this little owl-like bird?
Are there any sports for which the world's best player is female?
Yet another hash table in C
Chrysanthemum bejeweled with dew drops
Swapping "Good" and "Bad"
What is a "Lear Processor" and how did it work?
Why weren't bootable game disks ever a thing on the IBM PC?
Sorting and editing a text file to output a new file
sum pair of columns based on matching fieldsPrint top 5% values in a fileawk when string can be in different columnsHow to combine columns of two files, remove duplicates, and fill in missing linesSelectively output columns from a text fileExtracting a single line containing the highest value in a given column from a text file from each consecutively numbered sub-group/familycsv filter on linux bashCombine columns from several files into oneComparing all combinations of lines within two columns using awk + if statementHow to randomly change the order of two columns simultaneously for 1000 times using simulation values?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
There are few stages to this problem.
I have the following data and I want to sort it first on column 2 the 5 then 1.
Then I would like to combine columns 5 and 6 together with a deliminator.
When there is a change is values between the new 5 and 6 for it to print the new data. With at the top the new value from 5-6.
Maybe an example would help.
Original data.
fldr cable pdu_edit stu grnd_sta chan_pdu
64 3 1 13 145 156
66 3 1 13 145 156
79 1 1 9 97 108
117 3 1 13 145 156
240 3 1 13 145 156
255 3 1 13 145 156
263 3 1 13 145 156
291 3 1 13 145 156
817 1 1 9 97 108
946 1 1 9 97 108
What I would like to look like when it is printed:
Cable 1
97-108
79,817,946
Cable 3
145-156
64,66,117,240,255,263,291
awk scripting
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
add a comment |
There are few stages to this problem.
I have the following data and I want to sort it first on column 2 the 5 then 1.
Then I would like to combine columns 5 and 6 together with a deliminator.
When there is a change is values between the new 5 and 6 for it to print the new data. With at the top the new value from 5-6.
Maybe an example would help.
Original data.
fldr cable pdu_edit stu grnd_sta chan_pdu
64 3 1 13 145 156
66 3 1 13 145 156
79 1 1 9 97 108
117 3 1 13 145 156
240 3 1 13 145 156
255 3 1 13 145 156
263 3 1 13 145 156
291 3 1 13 145 156
817 1 1 9 97 108
946 1 1 9 97 108
What I would like to look like when it is printed:
Cable 1
97-108
79,817,946
Cable 3
145-156
64,66,117,240,255,263,291
awk scripting
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
1
Please edit your question to add that information
– muru
31 mins ago
add a comment |
There are few stages to this problem.
I have the following data and I want to sort it first on column 2 the 5 then 1.
Then I would like to combine columns 5 and 6 together with a deliminator.
When there is a change is values between the new 5 and 6 for it to print the new data. With at the top the new value from 5-6.
Maybe an example would help.
Original data.
fldr cable pdu_edit stu grnd_sta chan_pdu
64 3 1 13 145 156
66 3 1 13 145 156
79 1 1 9 97 108
117 3 1 13 145 156
240 3 1 13 145 156
255 3 1 13 145 156
263 3 1 13 145 156
291 3 1 13 145 156
817 1 1 9 97 108
946 1 1 9 97 108
What I would like to look like when it is printed:
Cable 1
97-108
79,817,946
Cable 3
145-156
64,66,117,240,255,263,291
awk scripting
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
There are few stages to this problem.
I have the following data and I want to sort it first on column 2 the 5 then 1.
Then I would like to combine columns 5 and 6 together with a deliminator.
When there is a change is values between the new 5 and 6 for it to print the new data. With at the top the new value from 5-6.
Maybe an example would help.
Original data.
fldr cable pdu_edit stu grnd_sta chan_pdu
64 3 1 13 145 156
66 3 1 13 145 156
79 1 1 9 97 108
117 3 1 13 145 156
240 3 1 13 145 156
255 3 1 13 145 156
263 3 1 13 145 156
291 3 1 13 145 156
817 1 1 9 97 108
946 1 1 9 97 108
What I would like to look like when it is printed:
Cable 1
97-108
79,817,946
Cable 3
145-156
64,66,117,240,255,263,291
awk scripting
awk scripting
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
edited 51 mins ago
Sparhawk
10.9k8 gold badges52 silver badges104 bronze badges
10.9k8 gold badges52 silver badges104 bronze badges
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
asked 1 hour ago
chats80chats80
1
1
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
New contributor
chats80 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
1
Please edit your question to add that information
– muru
31 mins ago
add a comment |
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
1
Please edit your question to add that information
– muru
31 mins ago
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
1
1
Please edit your question to add that information
– muru
31 mins ago
Please edit your question to add that information
– muru
31 mins ago
add a comment |
0
active
oldest
votes
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
});
}
});
chats80 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f529076%2fsorting-and-editing-a-text-file-to-output-a-new-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
chats80 is a new contributor. Be nice, and check out our Code of Conduct.
chats80 is a new contributor. Be nice, and check out our Code of Conduct.
chats80 is a new contributor. Be nice, and check out our Code of Conduct.
chats80 is a new contributor. Be nice, and check out our Code of Conduct.
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%2f529076%2fsorting-and-editing-a-text-file-to-output-a-new-file%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
Welcome! Could you describe what you have tried so far to make this work?
– Jeff H.
44 mins ago
I haven't been able to get very far. To sort it, I was using: sort -k2 -k5 -k1 filename.txt Then to print it I was using: awk '{if ($2==1 && $5==97) {print $1}}' filename.txt | xargs | sed -e 's/ /,/g' | sort But in the above case I am selecting the cable number and the number I am looking for in grnd_sta. However I am very new to this and I think I trying to run before I can walk. Not sure how to combine it together to produce an text file like the example. I was thinking I would have to use an if function so if there is a change in grnd_sta, in relation to the cable number.
– chats80
42 mins ago
1
Please edit your question to add that information
– muru
31 mins ago