Sort Command in Hidden Shell Scripts












0















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?










share|improve this question









New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    You have loaded the function using . .functions, but did you actually run the sort_credits function?

    – Olorin
    13 hours ago


















0















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?










share|improve this question









New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    You have loaded the function using . .functions, but did you actually run the sort_credits function?

    – Olorin
    13 hours ago
















0












0








0








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?










share|improve this question









New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












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






share|improve this question









New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 13 hours ago









Jeff Schaller

39.5k1054126




39.5k1054126






New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 13 hours ago









BobBob

1




1




New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2





    You have loaded the function using . .functions, but did you actually run the sort_credits function?

    – Olorin
    13 hours ago
















  • 2





    You have loaded the function using . .functions, but did you actually run the sort_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












1 Answer
1






active

oldest

votes


















0














I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.






share|improve this answer








New contributor




Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




















    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.










    draft saved

    draft discarded


















    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









    0














    I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.






    share|improve this answer








    New contributor




    Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.

























      0














      I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.






      share|improve this answer








      New contributor




      Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.























        0












        0








        0







        I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.






        share|improve this answer








        New contributor




        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.










        I figured it out. I was editing the .functions command but I never ran . .functions again and reloaded it into memory. Silly mistake.







        share|improve this answer








        New contributor




        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        share|improve this answer



        share|improve this answer






        New contributor




        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        answered 13 hours ago









        BobBob

        1




        1




        New contributor




        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.





        New contributor





        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






        Bob is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.






















            Bob is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Loup dans la culture

            How to solve the problem of ntp “Unable to contact time server” from KDE?

            ASUS Zenbook UX433/UX333 — Configure Touchpad-embedded numpad on Linux