Cut command Error: the delimiter must be a single character

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite












I am trying the following command on bash-4.3



$history | grep history | xargs cut -d ' ' -f1


but i am getting the following delimiter Error that I can't get rid of



cut: the delimiter must be a single character



I tried removing xargs but it gives a blank output. The whole idea is to get a particular command number from the history and then pass it to history -d to delete that particular command from the history. Here is just the output of



history | grep history



498 history | grep history | cat | xargs cut -d " " -f1
500 history | grep history | cat | xargs awk -ifs " "
501 history | grep history | xargs cut -d " " -f1
502 history | grep history | xargs cut -d '0' -f1
503 history | grep history | xargs cut -d 0 -f1
504* history |
505 history | ack history | xargs cut -d ' ' -f1
506 history | ack history | xargs cut -d ' ' -f1
507 history | ack history | cut -d ' ' -f1
508 history | grep history









share|improve this question



















  • 1




    Try it without the xargs. Although I'm not sure what this command is meant to do...
    – Stephen Harris
    5 hours ago










  • @StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
    – user2065276
    5 hours ago










  • So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
    – Stephen Harris
    5 hours ago










  • @StephenHarris What is wrong with my command. How can i fix it?
    – user2065276
    5 hours ago







  • 1




    cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
    – Stephen Harris
    5 hours ago














up vote
1
down vote

favorite












I am trying the following command on bash-4.3



$history | grep history | xargs cut -d ' ' -f1


but i am getting the following delimiter Error that I can't get rid of



cut: the delimiter must be a single character



I tried removing xargs but it gives a blank output. The whole idea is to get a particular command number from the history and then pass it to history -d to delete that particular command from the history. Here is just the output of



history | grep history



498 history | grep history | cat | xargs cut -d " " -f1
500 history | grep history | cat | xargs awk -ifs " "
501 history | grep history | xargs cut -d " " -f1
502 history | grep history | xargs cut -d '0' -f1
503 history | grep history | xargs cut -d 0 -f1
504* history |
505 history | ack history | xargs cut -d ' ' -f1
506 history | ack history | xargs cut -d ' ' -f1
507 history | ack history | cut -d ' ' -f1
508 history | grep history









share|improve this question



















  • 1




    Try it without the xargs. Although I'm not sure what this command is meant to do...
    – Stephen Harris
    5 hours ago










  • @StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
    – user2065276
    5 hours ago










  • So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
    – Stephen Harris
    5 hours ago










  • @StephenHarris What is wrong with my command. How can i fix it?
    – user2065276
    5 hours ago







  • 1




    cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
    – Stephen Harris
    5 hours ago












up vote
1
down vote

favorite









up vote
1
down vote

favorite











I am trying the following command on bash-4.3



$history | grep history | xargs cut -d ' ' -f1


but i am getting the following delimiter Error that I can't get rid of



cut: the delimiter must be a single character



I tried removing xargs but it gives a blank output. The whole idea is to get a particular command number from the history and then pass it to history -d to delete that particular command from the history. Here is just the output of



history | grep history



498 history | grep history | cat | xargs cut -d " " -f1
500 history | grep history | cat | xargs awk -ifs " "
501 history | grep history | xargs cut -d " " -f1
502 history | grep history | xargs cut -d '0' -f1
503 history | grep history | xargs cut -d 0 -f1
504* history |
505 history | ack history | xargs cut -d ' ' -f1
506 history | ack history | xargs cut -d ' ' -f1
507 history | ack history | cut -d ' ' -f1
508 history | grep history









share|improve this question















I am trying the following command on bash-4.3



$history | grep history | xargs cut -d ' ' -f1


but i am getting the following delimiter Error that I can't get rid of



cut: the delimiter must be a single character



I tried removing xargs but it gives a blank output. The whole idea is to get a particular command number from the history and then pass it to history -d to delete that particular command from the history. Here is just the output of



history | grep history



498 history | grep history | cat | xargs cut -d " " -f1
500 history | grep history | cat | xargs awk -ifs " "
501 history | grep history | xargs cut -d " " -f1
502 history | grep history | xargs cut -d '0' -f1
503 history | grep history | xargs cut -d 0 -f1
504* history |
505 history | ack history | xargs cut -d ' ' -f1
506 history | ack history | xargs cut -d ' ' -f1
507 history | ack history | cut -d ' ' -f1
508 history | grep history






grep command-history cut






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 5 hours ago

























asked 5 hours ago









user2065276

103




103







  • 1




    Try it without the xargs. Although I'm not sure what this command is meant to do...
    – Stephen Harris
    5 hours ago










  • @StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
    – user2065276
    5 hours ago










  • So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
    – Stephen Harris
    5 hours ago










  • @StephenHarris What is wrong with my command. How can i fix it?
    – user2065276
    5 hours ago







  • 1




    cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
    – Stephen Harris
    5 hours ago












  • 1




    Try it without the xargs. Although I'm not sure what this command is meant to do...
    – Stephen Harris
    5 hours ago










  • @StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
    – user2065276
    5 hours ago










  • So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
    – Stephen Harris
    5 hours ago










  • @StephenHarris What is wrong with my command. How can i fix it?
    – user2065276
    5 hours ago







  • 1




    cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
    – Stephen Harris
    5 hours ago







1




1




Try it without the xargs. Although I'm not sure what this command is meant to do...
– Stephen Harris
5 hours ago




Try it without the xargs. Although I'm not sure what this command is meant to do...
– Stephen Harris
5 hours ago












@StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
– user2065276
5 hours ago




@StephenHarris updated post. So the idea is to get a particular command number from the history and then pass it to history -d to delete a particular command from the history
– user2065276
5 hours ago












So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
– Stephen Harris
5 hours ago




So you probably want to use awk to get the first field. Something like history | awk '/command_to_search_for/ print $1'. That'll return the history number of "command_to_search_for"
– Stephen Harris
5 hours ago












@StephenHarris What is wrong with my command. How can i fix it?
– user2065276
5 hours ago





@StephenHarris What is wrong with my command. How can i fix it?
– user2065276
5 hours ago





1




1




cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
– Stephen Harris
5 hours ago




cut -d' ' will split on spaces... but there are multiple spaces and so -f1 will probably just return a space. awk print $1 is easier to get the first field. So you could do history | grep command_to_search_for | awk 'print $1' but that's simpler written with the history | awk command I suggested.
– Stephen Harris
5 hours ago










2 Answers
2






active

oldest

votes

















up vote
4
down vote



accepted










Some explanations:



  • You actually want the second field, so you need to change to `cut -d ' ' -f 2'.


  • xargs is not applicable here. What it does is take standard input and passes them as arguments to a command. However, cut operates on standard input by default, which is what you want. history | grep history | xargs cut […] ends up creating commands like cut […] [some content from the Bash history]'. To process a series of line numbers printed with a newline after each you'll want to use a while read loop:



    while IFS=$'n' read -r -u9 number
    do
    history -d "$number"
    done 9< <(history | grep […] | cut […])



  • some_command | cat | other_command is completely redundant. cat simply copies its standard input to standard output by default.





share|improve this answer





























    up vote
    4
    down vote













    Try this command



     history | grep history | awk NR==1'print $8 " " $9 " " $10 " " $11 " " $12 "" $13 '
    xargs cut -d ' '-f1


    NR==1: awk will read the cells in the first row of the table, then prints the columns relevant to "xargs cut -d ' '-f1" which are 8-12






    share|improve this answer






















    • please explain the awk syntax and arguments. Thanks
      – user2065276
      5 hours ago










    • What is wrong with my command. How can i fix it?
      – user2065276
      5 hours ago










    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472149%2fcut-command-error-the-delimiter-must-be-a-single-character%23new-answer', 'question_page');

    );

    Post as a guest






























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    Some explanations:



    • You actually want the second field, so you need to change to `cut -d ' ' -f 2'.


    • xargs is not applicable here. What it does is take standard input and passes them as arguments to a command. However, cut operates on standard input by default, which is what you want. history | grep history | xargs cut […] ends up creating commands like cut […] [some content from the Bash history]'. To process a series of line numbers printed with a newline after each you'll want to use a while read loop:



      while IFS=$'n' read -r -u9 number
      do
      history -d "$number"
      done 9< <(history | grep […] | cut […])



    • some_command | cat | other_command is completely redundant. cat simply copies its standard input to standard output by default.





    share|improve this answer


























      up vote
      4
      down vote



      accepted










      Some explanations:



      • You actually want the second field, so you need to change to `cut -d ' ' -f 2'.


      • xargs is not applicable here. What it does is take standard input and passes them as arguments to a command. However, cut operates on standard input by default, which is what you want. history | grep history | xargs cut […] ends up creating commands like cut […] [some content from the Bash history]'. To process a series of line numbers printed with a newline after each you'll want to use a while read loop:



        while IFS=$'n' read -r -u9 number
        do
        history -d "$number"
        done 9< <(history | grep […] | cut […])



      • some_command | cat | other_command is completely redundant. cat simply copies its standard input to standard output by default.





      share|improve this answer
























        up vote
        4
        down vote



        accepted







        up vote
        4
        down vote



        accepted






        Some explanations:



        • You actually want the second field, so you need to change to `cut -d ' ' -f 2'.


        • xargs is not applicable here. What it does is take standard input and passes them as arguments to a command. However, cut operates on standard input by default, which is what you want. history | grep history | xargs cut […] ends up creating commands like cut […] [some content from the Bash history]'. To process a series of line numbers printed with a newline after each you'll want to use a while read loop:



          while IFS=$'n' read -r -u9 number
          do
          history -d "$number"
          done 9< <(history | grep […] | cut […])



        • some_command | cat | other_command is completely redundant. cat simply copies its standard input to standard output by default.





        share|improve this answer














        Some explanations:



        • You actually want the second field, so you need to change to `cut -d ' ' -f 2'.


        • xargs is not applicable here. What it does is take standard input and passes them as arguments to a command. However, cut operates on standard input by default, which is what you want. history | grep history | xargs cut […] ends up creating commands like cut […] [some content from the Bash history]'. To process a series of line numbers printed with a newline after each you'll want to use a while read loop:



          while IFS=$'n' read -r -u9 number
          do
          history -d "$number"
          done 9< <(history | grep […] | cut […])



        • some_command | cat | other_command is completely redundant. cat simply copies its standard input to standard output by default.






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited 5 hours ago

























        answered 5 hours ago









        l0b0

        26.5k17106232




        26.5k17106232






















            up vote
            4
            down vote













            Try this command



             history | grep history | awk NR==1'print $8 " " $9 " " $10 " " $11 " " $12 "" $13 '
            xargs cut -d ' '-f1


            NR==1: awk will read the cells in the first row of the table, then prints the columns relevant to "xargs cut -d ' '-f1" which are 8-12






            share|improve this answer






















            • please explain the awk syntax and arguments. Thanks
              – user2065276
              5 hours ago










            • What is wrong with my command. How can i fix it?
              – user2065276
              5 hours ago














            up vote
            4
            down vote













            Try this command



             history | grep history | awk NR==1'print $8 " " $9 " " $10 " " $11 " " $12 "" $13 '
            xargs cut -d ' '-f1


            NR==1: awk will read the cells in the first row of the table, then prints the columns relevant to "xargs cut -d ' '-f1" which are 8-12






            share|improve this answer






















            • please explain the awk syntax and arguments. Thanks
              – user2065276
              5 hours ago










            • What is wrong with my command. How can i fix it?
              – user2065276
              5 hours ago












            up vote
            4
            down vote










            up vote
            4
            down vote









            Try this command



             history | grep history | awk NR==1'print $8 " " $9 " " $10 " " $11 " " $12 "" $13 '
            xargs cut -d ' '-f1


            NR==1: awk will read the cells in the first row of the table, then prints the columns relevant to "xargs cut -d ' '-f1" which are 8-12






            share|improve this answer














            Try this command



             history | grep history | awk NR==1'print $8 " " $9 " " $10 " " $11 " " $12 "" $13 '
            xargs cut -d ' '-f1


            NR==1: awk will read the cells in the first row of the table, then prints the columns relevant to "xargs cut -d ' '-f1" which are 8-12







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 5 hours ago

























            answered 5 hours ago









            Goro

            5,20552459




            5,20552459











            • please explain the awk syntax and arguments. Thanks
              – user2065276
              5 hours ago










            • What is wrong with my command. How can i fix it?
              – user2065276
              5 hours ago
















            • please explain the awk syntax and arguments. Thanks
              – user2065276
              5 hours ago










            • What is wrong with my command. How can i fix it?
              – user2065276
              5 hours ago















            please explain the awk syntax and arguments. Thanks
            – user2065276
            5 hours ago




            please explain the awk syntax and arguments. Thanks
            – user2065276
            5 hours ago












            What is wrong with my command. How can i fix it?
            – user2065276
            5 hours ago




            What is wrong with my command. How can i fix it?
            – user2065276
            5 hours ago

















             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f472149%2fcut-command-error-the-delimiter-must-be-a-single-character%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            Long meetings (6-7 hours a day): Being “babysat” by supervisor

            Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

            Confectionery