How to cut from one field to a different field in a separate output file? Announcing the...
If Windows 7 doesn't support WSL, then what is "Subsystem for UNIX-based Applications"?
Does the Black Tentacles spell do damage twice at the start of turn to an already restrained creature?
Monty Hall Problem-Probability Paradox
Why is a lens darker than other ones when applying the same settings?
Is multiple magic items in one inherently imbalanced?
As a dual citizen, my US passport will expire one day after traveling to the US. Will this work?
Random body shuffle every night—can we still function?
Why shouldn't this prove the Prime Number Theorem?
Why complex landing gears are used instead of simple,reliability and light weight muscle wire or shape memory alloys?
Co-worker has annoying ringtone
Why is std::move not [[nodiscard]] in C++20?
Mounting TV on a weird wall that has some material between the drywall and stud
How to change the tick of the color bar legend to black
How to align enumerate environment inside description environment
Why not send Voyager 3 and 4 following up the paths taken by Voyager 1 and 2 to re-transmit signals of later as they fly away from Earth?
Can two people see the same photon?
How can a team of shapeshifters communicate?
What is the "studentd" process?
What order were files/directories output in dir?
After Sam didn't return home in the end, were he and Al still friends?
What does Turing mean by this statement?
Test print coming out spongy
Why datecode is SO IMPORTANT to chip manufacturers?
Can you force honesty by using the Speak with Dead and Zone of Truth spells together?
How to cut from one field to a different field in a separate output file?
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
2019 Community Moderator Election Results
Why I closed the “Why is Kali so hard” questionIs there a robust command line tool for processing csv files?Cut on both characters and fieldEasily get a particular column from output without sed or awkWhat command(s) will feed a tab-delimited text file and cut each line to 80 characters?Cutting logs (and not copying) from a log file between two time stampsBash to join columns from multiple filesHow do I extract the second and third columns from my CSV file with awk?Deleting extension only from the first columnHow do I cut word and value from cut command field value?awk from different lines
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}
I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab.
I am trying to swap the columns by using the cut command and saving the cut command output to another file. I have no problem cutting field 2 and saving the output to the copynumber file. But I don't know how to cut field 1 to field 2 in the output file.
I am looking for solutions that only use bash shell scripting rather than any other languages like awk.
#I have tried the following commands:
$cat numbers
1 2
10 20
100 200
1000 2000
10000 20000
100000 300000
1000000 3000000
cat numbers | cut -f 2 > copynumbers
#How do I get field 1 from the original file into field 2 of the output file?
$cat copynumbers
2
20
200
2000
20000
300000
3000000
shell-script text-processing text-formatting cut
New contributor
add a comment |
I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab.
I am trying to swap the columns by using the cut command and saving the cut command output to another file. I have no problem cutting field 2 and saving the output to the copynumber file. But I don't know how to cut field 1 to field 2 in the output file.
I am looking for solutions that only use bash shell scripting rather than any other languages like awk.
#I have tried the following commands:
$cat numbers
1 2
10 20
100 200
1000 2000
10000 20000
100000 300000
1000000 3000000
cat numbers | cut -f 2 > copynumbers
#How do I get field 1 from the original file into field 2 of the output file?
$cat copynumbers
2
20
200
2000
20000
300000
3000000
shell-script text-processing text-formatting cut
New contributor
First, you don't needcat
. Second,awk
is lightyears better for what you are trying to do if you just put in the effort.
– Nasir Riley
37 mins ago
add a comment |
I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab.
I am trying to swap the columns by using the cut command and saving the cut command output to another file. I have no problem cutting field 2 and saving the output to the copynumber file. But I don't know how to cut field 1 to field 2 in the output file.
I am looking for solutions that only use bash shell scripting rather than any other languages like awk.
#I have tried the following commands:
$cat numbers
1 2
10 20
100 200
1000 2000
10000 20000
100000 300000
1000000 3000000
cat numbers | cut -f 2 > copynumbers
#How do I get field 1 from the original file into field 2 of the output file?
$cat copynumbers
2
20
200
2000
20000
300000
3000000
shell-script text-processing text-formatting cut
New contributor
I am trying to understand cut better and moving cut data to another file. I have a file called numbers with two columns. Each column is separated with one tab.
I am trying to swap the columns by using the cut command and saving the cut command output to another file. I have no problem cutting field 2 and saving the output to the copynumber file. But I don't know how to cut field 1 to field 2 in the output file.
I am looking for solutions that only use bash shell scripting rather than any other languages like awk.
#I have tried the following commands:
$cat numbers
1 2
10 20
100 200
1000 2000
10000 20000
100000 300000
1000000 3000000
cat numbers | cut -f 2 > copynumbers
#How do I get field 1 from the original file into field 2 of the output file?
$cat copynumbers
2
20
200
2000
20000
300000
3000000
shell-script text-processing text-formatting cut
shell-script text-processing text-formatting cut
New contributor
New contributor
edited 42 mins ago
Jeff Schaller♦
45.1k1164147
45.1k1164147
New contributor
asked 44 mins ago
R00ki3 M1stak3R00ki3 M1stak3
11
11
New contributor
New contributor
First, you don't needcat
. Second,awk
is lightyears better for what you are trying to do if you just put in the effort.
– Nasir Riley
37 mins ago
add a comment |
First, you don't needcat
. Second,awk
is lightyears better for what you are trying to do if you just put in the effort.
– Nasir Riley
37 mins ago
First, you don't need
cat
. Second, awk
is lightyears better for what you are trying to do if you just put in the effort.– Nasir Riley
37 mins ago
First, you don't need
cat
. Second, awk
is lightyears better for what you are trying to do if you just put in the effort.– Nasir Riley
37 mins ago
add a comment |
1 Answer
1
active
oldest
votes
Using process substitution and paste
:
$ paste <(cut -f2 numbers) <(cut -f1 numbers)
2 1
20 10
200 100
2000 1000
20000 10000
300000 100000
3000000 1000000
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
});
}
});
R00ki3 M1stak3 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%2f513617%2fhow-to-cut-from-one-field-to-a-different-field-in-a-separate-output-file%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
Using process substitution and paste
:
$ paste <(cut -f2 numbers) <(cut -f1 numbers)
2 1
20 10
200 100
2000 1000
20000 10000
300000 100000
3000000 1000000
add a comment |
Using process substitution and paste
:
$ paste <(cut -f2 numbers) <(cut -f1 numbers)
2 1
20 10
200 100
2000 1000
20000 10000
300000 100000
3000000 1000000
add a comment |
Using process substitution and paste
:
$ paste <(cut -f2 numbers) <(cut -f1 numbers)
2 1
20 10
200 100
2000 1000
20000 10000
300000 100000
3000000 1000000
Using process substitution and paste
:
$ paste <(cut -f2 numbers) <(cut -f1 numbers)
2 1
20 10
200 100
2000 1000
20000 10000
300000 100000
3000000 1000000
answered 36 mins ago
steeldriversteeldriver
38.1k45489
38.1k45489
add a comment |
add a comment |
R00ki3 M1stak3 is a new contributor. Be nice, and check out our Code of Conduct.
R00ki3 M1stak3 is a new contributor. Be nice, and check out our Code of Conduct.
R00ki3 M1stak3 is a new contributor. Be nice, and check out our Code of Conduct.
R00ki3 M1stak3 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%2f513617%2fhow-to-cut-from-one-field-to-a-different-field-in-a-separate-output-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
First, you don't need
cat
. Second,awk
is lightyears better for what you are trying to do if you just put in the effort.– Nasir Riley
37 mins ago