Sort Command in Hidden Shell Scripts
I have a file called student_data
1001:Jones:Alice:Accounting:105
1320:Moore:Sarah:Mechanical Engineering:80
2100:Olson:Timothy:Computer Systems:66
1520:Mitchell:Barbara:Electrical Engineering:34
1800:Smith:Paul:Mathematics:87
2010:Whitman:Henry:Business Management:114
1480:Richard:Johnson:Computer Systems:90
1234:Willims:David:Economics:78
that I want to sort. When I run :
sort -k 5 -t: student_data
I don't get a list of student_data sorted by the 5th column. If I run
sort -k 5 -t: -n student_data
I do get a list sorted by the fifth column in numerical order. I'm trying to use this command inside a hidden shell script called .functions
sort_credits()
{
sort -k 5 -t: -n student_data
}
But when I load the shell script using . .functions, I cannot get the list to sort by the 5th column, using the first or second listed command. Anyone know what the issue is here?
linux sort function
New contributor
add a comment |
I have a file called student_data
1001:Jones:Alice:Accounting:105
1320:Moore:Sarah:Mechanical Engineering:80
2100:Olson:Timothy:Computer Systems:66
1520:Mitchell:Barbara:Electrical Engineering:34
1800:Smith:Paul:Mathematics:87
2010:Whitman:Henry:Business Management:114
1480:Richard:Johnson:Computer Systems:90
1234:Willims:David:Economics:78
that I want to sort. When I run :
sort -k 5 -t: student_data
I don't get a list of student_data sorted by the 5th column. If I run
sort -k 5 -t: -n student_data
I do get a list sorted by the fifth column in numerical order. I'm trying to use this command inside a hidden shell script called .functions
sort_credits()
{
sort -k 5 -t: -n student_data
}
But when I load the shell script using . .functions, I cannot get the list to sort by the 5th column, using the first or second listed command. Anyone know what the issue is here?
linux sort function
New contributor
2
You have loaded the function using. .functions
, but did you actually run thesort_credits
function?
– Olorin
13 hours ago
add a comment |
I have a file called student_data
1001:Jones:Alice:Accounting:105
1320:Moore:Sarah:Mechanical Engineering:80
2100:Olson:Timothy:Computer Systems:66
1520:Mitchell:Barbara:Electrical Engineering:34
1800:Smith:Paul:Mathematics:87
2010:Whitman:Henry:Business Management:114
1480:Richard:Johnson:Computer Systems:90
1234:Willims:David:Economics:78
that I want to sort. When I run :
sort -k 5 -t: student_data
I don't get a list of student_data sorted by the 5th column. If I run
sort -k 5 -t: -n student_data
I do get a list sorted by the fifth column in numerical order. I'm trying to use this command inside a hidden shell script called .functions
sort_credits()
{
sort -k 5 -t: -n student_data
}
But when I load the shell script using . .functions, I cannot get the list to sort by the 5th column, using the first or second listed command. Anyone know what the issue is here?
linux sort function
New contributor
I have a file called student_data
1001:Jones:Alice:Accounting:105
1320:Moore:Sarah:Mechanical Engineering:80
2100:Olson:Timothy:Computer Systems:66
1520:Mitchell:Barbara:Electrical Engineering:34
1800:Smith:Paul:Mathematics:87
2010:Whitman:Henry:Business Management:114
1480:Richard:Johnson:Computer Systems:90
1234:Willims:David:Economics:78
that I want to sort. When I run :
sort -k 5 -t: student_data
I don't get a list of student_data sorted by the 5th column. If I run
sort -k 5 -t: -n student_data
I do get a list sorted by the fifth column in numerical order. I'm trying to use this command inside a hidden shell script called .functions
sort_credits()
{
sort -k 5 -t: -n student_data
}
But when I load the shell script using . .functions, I cannot get the list to sort by the 5th column, using the first or second listed command. Anyone know what the issue is here?
linux sort function
linux sort function
New contributor
New contributor
edited 13 hours ago
Jeff Schaller
39.5k1054126
39.5k1054126
New contributor
asked 13 hours ago
BobBob
1
1
New contributor
New contributor
2
You have loaded the function using. .functions
, but did you actually run thesort_credits
function?
– Olorin
13 hours ago
add a comment |
2
You have loaded the function using. .functions
, but did you actually run thesort_credits
function?
– Olorin
13 hours ago
2
2
You have loaded the function using
. .functions
, but did you actually run the sort_credits
function?– Olorin
13 hours ago
You have loaded the function using
. .functions
, but did you actually run the sort_credits
function?– Olorin
13 hours ago
add a comment |
1 Answer
1
active
oldest
votes
I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.
New contributor
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
});
}
});
Bob 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%2f495198%2fsort-command-in-hidden-shell-scripts%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
I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.
New contributor
add a comment |
I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.
New contributor
add a comment |
I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.
New contributor
I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.
New contributor
New contributor
answered 13 hours ago
BobBob
1
1
New contributor
New contributor
add a comment |
add a comment |
Bob is a new contributor. Be nice, and check out our Code of Conduct.
Bob is a new contributor. Be nice, and check out our Code of Conduct.
Bob is a new contributor. Be nice, and check out our Code of Conduct.
Bob 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%2f495198%2fsort-command-in-hidden-shell-scripts%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
2
You have loaded the function using
. .functions
, but did you actually run thesort_credits
function?– Olorin
13 hours ago