Remove words (letters followed by space) from a specific column

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











up vote
1
down vote

favorite












I have a file and the format is as follows:



cat dog AHF123432 | 123432 | dhfshfjdh
lion AFG23412 |23412 | dfshjhfjdhj


I need to remove those words from first column which contains only alphabets i.e., cat(followed by space) and dog from first row
and lion from the second row



My output will look something like:



AHF123432 | 123432 | dhfshfjdh 
AFG23412 | 23412 | dhfshfjdh









share|improve this question























  • what did you try? Do you have some regular expression?
    – Jakuje
    Aug 12 '15 at 17:54











  • Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
    – frozen_dreams
    Aug 12 '15 at 18:10















up vote
1
down vote

favorite












I have a file and the format is as follows:



cat dog AHF123432 | 123432 | dhfshfjdh
lion AFG23412 |23412 | dfshjhfjdhj


I need to remove those words from first column which contains only alphabets i.e., cat(followed by space) and dog from first row
and lion from the second row



My output will look something like:



AHF123432 | 123432 | dhfshfjdh 
AFG23412 | 23412 | dhfshfjdh









share|improve this question























  • what did you try? Do you have some regular expression?
    – Jakuje
    Aug 12 '15 at 17:54











  • Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
    – frozen_dreams
    Aug 12 '15 at 18:10













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have a file and the format is as follows:



cat dog AHF123432 | 123432 | dhfshfjdh
lion AFG23412 |23412 | dfshjhfjdhj


I need to remove those words from first column which contains only alphabets i.e., cat(followed by space) and dog from first row
and lion from the second row



My output will look something like:



AHF123432 | 123432 | dhfshfjdh 
AFG23412 | 23412 | dhfshfjdh









share|improve this question















I have a file and the format is as follows:



cat dog AHF123432 | 123432 | dhfshfjdh
lion AFG23412 |23412 | dfshjhfjdhj


I need to remove those words from first column which contains only alphabets i.e., cat(followed by space) and dog from first row
and lion from the second row



My output will look something like:



AHF123432 | 123432 | dhfshfjdh 
AFG23412 | 23412 | dhfshfjdh






text-processing awk grep regular-expression






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 14:22









Rui F Ribeiro

38.3k1475126




38.3k1475126










asked Aug 12 '15 at 17:38









frozen_dreams

84




84











  • what did you try? Do you have some regular expression?
    – Jakuje
    Aug 12 '15 at 17:54











  • Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
    – frozen_dreams
    Aug 12 '15 at 18:10

















  • what did you try? Do you have some regular expression?
    – Jakuje
    Aug 12 '15 at 17:54











  • Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
    – frozen_dreams
    Aug 12 '15 at 18:10
















what did you try? Do you have some regular expression?
– Jakuje
Aug 12 '15 at 17:54





what did you try? Do you have some regular expression?
– Jakuje
Aug 12 '15 at 17:54













Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
– frozen_dreams
Aug 12 '15 at 18:10





Hi Jakuje. I'm a newbie to Linux. I tried with cut grep and awk. cut -d' ' -f2- grep -Ev '^[a-zA-Z]>' awk '$1 !~ /[a-zA-Z]/' But nothing worked as expected.
– frozen_dreams
Aug 12 '15 at 18:10











3 Answers
3






active

oldest

votes

















up vote
1
down vote



accepted










This removes all pure-alphabetic words from the beginning of the line:



$ sed -r 's/^([[:alpha:]]* )*//' filename.tsv
AHF123432 | 123432 | dhfshfjdh
AFG23412 |23412 | dfshjhfjdhj


Or, to save the output in a new file:



sed -r 's/^([[:alpha:]]* )*//' filename.tsv > final.tsv


How it works




  • [[:alpha:]]* matches any number of alphabetic characters followed by a space. In other words, it matches a word followed by a space.



    In more detail, [[:alpha:]] matches a single alphabetic character. ``[[:alpha:]]*` matches any number of such characters.



  • ([[:alpha:]]* )* matches any number of such words followed by spaces.


  • ^([[:alpha:]]* )* matches any any number of words followed by spaces but, because of the ^, only starting from the beginning of the line.


  • The substitute command removes all those matching words. The substitute command has the form s/old/new/ where, here, old is our expression above which matches any number of words starting from the beginning of the line. We want to replace these words with nothing so, here, we use the empty string for new.


In olden times, the regular expression to match an alphabetic characters was [a-zA-Z]. With modern unicode fonts, that is now longer reliable. Because our regular expression above uses [:alpha:], it is unicode-safe.






share|improve this answer






















  • Hi John, I tried your answer, but an error states -E invalid option..
    – frozen_dreams
    Aug 12 '15 at 18:28










  • -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
    – John1024
    Aug 12 '15 at 18:31











  • I'm working on PUTTY.
    – frozen_dreams
    Aug 12 '15 at 18:31










  • OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
    – John1024
    Aug 12 '15 at 18:34










  • Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
    – frozen_dreams
    Aug 12 '15 at 18:34


















up vote
0
down vote













If your grep supports perl compatible regular expressions:



grep -Po '^([a-z]* +)*K.*'


or



pcregrep -o '^([a-z]* +)*K.*'





share|improve this answer




















  • Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
    – frozen_dreams
    Aug 12 '15 at 18:23










  • @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
    – jimmij
    Aug 12 '15 at 18:52











  • grep (GNU grep 2.7)
    – frozen_dreams
    Aug 12 '15 at 18:56

















up vote
0
down vote













Using awk



awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo



Example



% cat foo
cat dog AHF123432 | 123432 | dhfshfjdh
lion AFG23412 | 23412 | dfshjhfjdh

% awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo
AHF123432 | 123432 | dhfshfjdh
AFG23412 | 23412 | dfshjhfjdh





share|improve this answer




















    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: 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
    );



    );













     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f222841%2fremove-words-letters-followed-by-space-from-a-specific-column%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote



    accepted










    This removes all pure-alphabetic words from the beginning of the line:



    $ sed -r 's/^([[:alpha:]]* )*//' filename.tsv
    AHF123432 | 123432 | dhfshfjdh
    AFG23412 |23412 | dfshjhfjdhj


    Or, to save the output in a new file:



    sed -r 's/^([[:alpha:]]* )*//' filename.tsv > final.tsv


    How it works




    • [[:alpha:]]* matches any number of alphabetic characters followed by a space. In other words, it matches a word followed by a space.



      In more detail, [[:alpha:]] matches a single alphabetic character. ``[[:alpha:]]*` matches any number of such characters.



    • ([[:alpha:]]* )* matches any number of such words followed by spaces.


    • ^([[:alpha:]]* )* matches any any number of words followed by spaces but, because of the ^, only starting from the beginning of the line.


    • The substitute command removes all those matching words. The substitute command has the form s/old/new/ where, here, old is our expression above which matches any number of words starting from the beginning of the line. We want to replace these words with nothing so, here, we use the empty string for new.


    In olden times, the regular expression to match an alphabetic characters was [a-zA-Z]. With modern unicode fonts, that is now longer reliable. Because our regular expression above uses [:alpha:], it is unicode-safe.






    share|improve this answer






















    • Hi John, I tried your answer, but an error states -E invalid option..
      – frozen_dreams
      Aug 12 '15 at 18:28










    • -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
      – John1024
      Aug 12 '15 at 18:31











    • I'm working on PUTTY.
      – frozen_dreams
      Aug 12 '15 at 18:31










    • OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
      – John1024
      Aug 12 '15 at 18:34










    • Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
      – frozen_dreams
      Aug 12 '15 at 18:34















    up vote
    1
    down vote



    accepted










    This removes all pure-alphabetic words from the beginning of the line:



    $ sed -r 's/^([[:alpha:]]* )*//' filename.tsv
    AHF123432 | 123432 | dhfshfjdh
    AFG23412 |23412 | dfshjhfjdhj


    Or, to save the output in a new file:



    sed -r 's/^([[:alpha:]]* )*//' filename.tsv > final.tsv


    How it works




    • [[:alpha:]]* matches any number of alphabetic characters followed by a space. In other words, it matches a word followed by a space.



      In more detail, [[:alpha:]] matches a single alphabetic character. ``[[:alpha:]]*` matches any number of such characters.



    • ([[:alpha:]]* )* matches any number of such words followed by spaces.


    • ^([[:alpha:]]* )* matches any any number of words followed by spaces but, because of the ^, only starting from the beginning of the line.


    • The substitute command removes all those matching words. The substitute command has the form s/old/new/ where, here, old is our expression above which matches any number of words starting from the beginning of the line. We want to replace these words with nothing so, here, we use the empty string for new.


    In olden times, the regular expression to match an alphabetic characters was [a-zA-Z]. With modern unicode fonts, that is now longer reliable. Because our regular expression above uses [:alpha:], it is unicode-safe.






    share|improve this answer






















    • Hi John, I tried your answer, but an error states -E invalid option..
      – frozen_dreams
      Aug 12 '15 at 18:28










    • -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
      – John1024
      Aug 12 '15 at 18:31











    • I'm working on PUTTY.
      – frozen_dreams
      Aug 12 '15 at 18:31










    • OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
      – John1024
      Aug 12 '15 at 18:34










    • Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
      – frozen_dreams
      Aug 12 '15 at 18:34













    up vote
    1
    down vote



    accepted







    up vote
    1
    down vote



    accepted






    This removes all pure-alphabetic words from the beginning of the line:



    $ sed -r 's/^([[:alpha:]]* )*//' filename.tsv
    AHF123432 | 123432 | dhfshfjdh
    AFG23412 |23412 | dfshjhfjdhj


    Or, to save the output in a new file:



    sed -r 's/^([[:alpha:]]* )*//' filename.tsv > final.tsv


    How it works




    • [[:alpha:]]* matches any number of alphabetic characters followed by a space. In other words, it matches a word followed by a space.



      In more detail, [[:alpha:]] matches a single alphabetic character. ``[[:alpha:]]*` matches any number of such characters.



    • ([[:alpha:]]* )* matches any number of such words followed by spaces.


    • ^([[:alpha:]]* )* matches any any number of words followed by spaces but, because of the ^, only starting from the beginning of the line.


    • The substitute command removes all those matching words. The substitute command has the form s/old/new/ where, here, old is our expression above which matches any number of words starting from the beginning of the line. We want to replace these words with nothing so, here, we use the empty string for new.


    In olden times, the regular expression to match an alphabetic characters was [a-zA-Z]. With modern unicode fonts, that is now longer reliable. Because our regular expression above uses [:alpha:], it is unicode-safe.






    share|improve this answer














    This removes all pure-alphabetic words from the beginning of the line:



    $ sed -r 's/^([[:alpha:]]* )*//' filename.tsv
    AHF123432 | 123432 | dhfshfjdh
    AFG23412 |23412 | dfshjhfjdhj


    Or, to save the output in a new file:



    sed -r 's/^([[:alpha:]]* )*//' filename.tsv > final.tsv


    How it works




    • [[:alpha:]]* matches any number of alphabetic characters followed by a space. In other words, it matches a word followed by a space.



      In more detail, [[:alpha:]] matches a single alphabetic character. ``[[:alpha:]]*` matches any number of such characters.



    • ([[:alpha:]]* )* matches any number of such words followed by spaces.


    • ^([[:alpha:]]* )* matches any any number of words followed by spaces but, because of the ^, only starting from the beginning of the line.


    • The substitute command removes all those matching words. The substitute command has the form s/old/new/ where, here, old is our expression above which matches any number of words starting from the beginning of the line. We want to replace these words with nothing so, here, we use the empty string for new.


    In olden times, the regular expression to match an alphabetic characters was [a-zA-Z]. With modern unicode fonts, that is now longer reliable. Because our regular expression above uses [:alpha:], it is unicode-safe.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 12 '15 at 18:29

























    answered Aug 12 '15 at 18:20









    John1024

    45.4k4102118




    45.4k4102118











    • Hi John, I tried your answer, but an error states -E invalid option..
      – frozen_dreams
      Aug 12 '15 at 18:28










    • -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
      – John1024
      Aug 12 '15 at 18:31











    • I'm working on PUTTY.
      – frozen_dreams
      Aug 12 '15 at 18:31










    • OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
      – John1024
      Aug 12 '15 at 18:34










    • Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
      – frozen_dreams
      Aug 12 '15 at 18:34

















    • Hi John, I tried your answer, but an error states -E invalid option..
      – frozen_dreams
      Aug 12 '15 at 18:28










    • -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
      – John1024
      Aug 12 '15 at 18:31











    • I'm working on PUTTY.
      – frozen_dreams
      Aug 12 '15 at 18:31










    • OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
      – John1024
      Aug 12 '15 at 18:34










    • Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
      – frozen_dreams
      Aug 12 '15 at 18:34
















    Hi John, I tried your answer, but an error states -E invalid option..
    – frozen_dreams
    Aug 12 '15 at 18:28




    Hi John, I tried your answer, but an error states -E invalid option..
    – frozen_dreams
    Aug 12 '15 at 18:28












    -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
    – John1024
    Aug 12 '15 at 18:31





    -E works on BSD sed and the newer GNU sed versions. Try -r instead. Answer updated.
    – John1024
    Aug 12 '15 at 18:31













    I'm working on PUTTY.
    – frozen_dreams
    Aug 12 '15 at 18:31




    I'm working on PUTTY.
    – frozen_dreams
    Aug 12 '15 at 18:31












    OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
    – John1024
    Aug 12 '15 at 18:34




    OK. Please try with -r as in the updated answer. (PUTTY is communication system. If -r doesn't work either, it would be helpful to know what operating system is on the other end of the PUTTY communication channel.)
    – John1024
    Aug 12 '15 at 18:34












    Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
    – frozen_dreams
    Aug 12 '15 at 18:34





    Hi John, with -r option. The output looks like this: dog AHF123432 | 123432 | dhfshfjdh lion AFG23412 |23412 | dfshjhfjdhj Only the cat from the first row is removed. Rest all remains the same
    – frozen_dreams
    Aug 12 '15 at 18:34













    up vote
    0
    down vote













    If your grep supports perl compatible regular expressions:



    grep -Po '^([a-z]* +)*K.*'


    or



    pcregrep -o '^([a-z]* +)*K.*'





    share|improve this answer




















    • Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
      – frozen_dreams
      Aug 12 '15 at 18:23










    • @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
      – jimmij
      Aug 12 '15 at 18:52











    • grep (GNU grep 2.7)
      – frozen_dreams
      Aug 12 '15 at 18:56














    up vote
    0
    down vote













    If your grep supports perl compatible regular expressions:



    grep -Po '^([a-z]* +)*K.*'


    or



    pcregrep -o '^([a-z]* +)*K.*'





    share|improve this answer




















    • Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
      – frozen_dreams
      Aug 12 '15 at 18:23










    • @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
      – jimmij
      Aug 12 '15 at 18:52











    • grep (GNU grep 2.7)
      – frozen_dreams
      Aug 12 '15 at 18:56












    up vote
    0
    down vote










    up vote
    0
    down vote









    If your grep supports perl compatible regular expressions:



    grep -Po '^([a-z]* +)*K.*'


    or



    pcregrep -o '^([a-z]* +)*K.*'





    share|improve this answer












    If your grep supports perl compatible regular expressions:



    grep -Po '^([a-z]* +)*K.*'


    or



    pcregrep -o '^([a-z]* +)*K.*'






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 12 '15 at 18:14









    jimmij

    30.3k868102




    30.3k868102











    • Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
      – frozen_dreams
      Aug 12 '15 at 18:23










    • @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
      – jimmij
      Aug 12 '15 at 18:52











    • grep (GNU grep 2.7)
      – frozen_dreams
      Aug 12 '15 at 18:56
















    • Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
      – frozen_dreams
      Aug 12 '15 at 18:23










    • @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
      – jimmij
      Aug 12 '15 at 18:52











    • grep (GNU grep 2.7)
      – frozen_dreams
      Aug 12 '15 at 18:56















    Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
    – frozen_dreams
    Aug 12 '15 at 18:23




    Hi Jimmij, sorry to say.. dint work.. Let me know if this is correct way: pcregrep -o '^([a-z]* +)+K.*' filename.tsv > final.tsv
    – frozen_dreams
    Aug 12 '15 at 18:23












    @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
    – jimmij
    Aug 12 '15 at 18:52





    @frozen_dreams what's the output of grep --version, pcregrep --version, and what exactly means "didn't work"?
    – jimmij
    Aug 12 '15 at 18:52













    grep (GNU grep 2.7)
    – frozen_dreams
    Aug 12 '15 at 18:56




    grep (GNU grep 2.7)
    – frozen_dreams
    Aug 12 '15 at 18:56










    up vote
    0
    down vote













    Using awk



    awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo



    Example



    % cat foo
    cat dog AHF123432 | 123432 | dhfshfjdh
    lion AFG23412 | 23412 | dfshjhfjdh

    % awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo
    AHF123432 | 123432 | dhfshfjdh
    AFG23412 | 23412 | dfshjhfjdh





    share|improve this answer
























      up vote
      0
      down vote













      Using awk



      awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo



      Example



      % cat foo
      cat dog AHF123432 | 123432 | dhfshfjdh
      lion AFG23412 | 23412 | dfshjhfjdh

      % awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo
      AHF123432 | 123432 | dhfshfjdh
      AFG23412 | 23412 | dfshjhfjdh





      share|improve this answer






















        up vote
        0
        down vote










        up vote
        0
        down vote









        Using awk



        awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo



        Example



        % cat foo
        cat dog AHF123432 | 123432 | dhfshfjdh
        lion AFG23412 | 23412 | dfshjhfjdh

        % awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo
        AHF123432 | 123432 | dhfshfjdh
        AFG23412 | 23412 | dfshjhfjdh





        share|improve this answer












        Using awk



        awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo



        Example



        % cat foo
        cat dog AHF123432 | 123432 | dhfshfjdh
        lion AFG23412 | 23412 | dfshjhfjdh

        % awk -F'|' 'for (i=1; i<=NF;i++) [A-Z])+ /,"",$i); printf "%s",$i; if(i<NF) printf " else printf "n"' foo
        AHF123432 | 123432 | dhfshfjdh
        AFG23412 | 23412 | dfshjhfjdh






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 13 '15 at 6:47









        A.B.

        2,499726




        2,499726



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f222841%2fremove-words-letters-followed-by-space-from-a-specific-column%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

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay