Aliased an awk command successfully now won't use OFS [closed]

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











up vote
1
down vote

favorite












So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!



 alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"


A variation of the above is what I put into my alias.







share|improve this question













closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm♦ Jun 28 at 3:23


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    What's the alias?
    – Kusalananda
    Jun 27 at 20:20










  • edited this to show the alias.
    – trazinaz
    Jun 27 at 21:04










  • I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
    – ilkkachu
    Jun 27 at 21:14














up vote
1
down vote

favorite












So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!



 alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"


A variation of the above is what I put into my alias.







share|improve this question













closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm♦ Jun 28 at 3:23


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 2




    What's the alias?
    – Kusalananda
    Jun 27 at 20:20










  • edited this to show the alias.
    – trazinaz
    Jun 27 at 21:04










  • I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
    – ilkkachu
    Jun 27 at 21:14












up vote
1
down vote

favorite









up vote
1
down vote

favorite











So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!



 alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"


A variation of the above is what I put into my alias.







share|improve this question













So I was able to get a command finally with the ability to get and grep the information from a specific file I wanted and then I ran into a problem with alias:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


From there I was able to figure out that I needed to change my alias after looking it up and I did it as such:



find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='n' 'print $5, $1, $2, $3 '


So now it prints but I still wanted to use the OFS but I am not sure the syntax to get the OFS to load. Thanks in advance!



 alias aliascommand="find ./ -type f -name filename.ext -exec grep 'information' + | sort | awk -v OFS='t' 'print $5 $1 $2 $3 '"


A variation of the above is what I put into my alias.









share|improve this question












share|improve this question




share|improve this question








edited Jun 27 at 21:01









ilkkachu

47.3k668130




47.3k668130









asked Jun 27 at 20:19









trazinaz

262




262




closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm♦ Jun 28 at 3:23


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






closed as unclear what you're asking by Kusalananda, Tomasz, jasonwryan, slm♦ Jun 28 at 3:23


Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 2




    What's the alias?
    – Kusalananda
    Jun 27 at 20:20










  • edited this to show the alias.
    – trazinaz
    Jun 27 at 21:04










  • I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
    – ilkkachu
    Jun 27 at 21:14












  • 2




    What's the alias?
    – Kusalananda
    Jun 27 at 20:20










  • edited this to show the alias.
    – trazinaz
    Jun 27 at 21:04










  • I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
    – ilkkachu
    Jun 27 at 21:14







2




2




What's the alias?
– Kusalananda
Jun 27 at 20:20




What's the alias?
– Kusalananda
Jun 27 at 20:20












edited this to show the alias.
– trazinaz
Jun 27 at 21:04




edited this to show the alias.
– trazinaz
Jun 27 at 21:04












I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
– ilkkachu
Jun 27 at 21:14




I'm not sure why you have the backslash before OFS, but I also can't see any problems with that, with or without the backslash.
– ilkkachu
Jun 27 at 21:14










1 Answer
1






active

oldest

votes

















up vote
0
down vote













If you do:



alias foo="...'print $5 $1 $2 $3 '"


The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.



That n should be fine within the double quotes, though.



In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.



mycommand() 
sort





share|improve this answer




























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    0
    down vote













    If you do:



    alias foo="...'print $5 $1 $2 $3 '"


    The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.



    That n should be fine within the double quotes, though.



    In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.



    mycommand() 
    sort





    share|improve this answer

























      up vote
      0
      down vote













      If you do:



      alias foo="...'print $5 $1 $2 $3 '"


      The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.



      That n should be fine within the double quotes, though.



      In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.



      mycommand() 
      sort





      share|improve this answer























        up vote
        0
        down vote










        up vote
        0
        down vote









        If you do:



        alias foo="...'print $5 $1 $2 $3 '"


        The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.



        That n should be fine within the double quotes, though.



        In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.



        mycommand() 
        sort





        share|improve this answer













        If you do:



        alias foo="...'print $5 $1 $2 $3 '"


        The positional parameters will be expanded when the alias is set. They are within a double-quoted string, after all. You don't want that, so you had to escape them with backslashes. Alternatively, you could have put the whole alias text in single-quotes, but since you want to use single quotes in the alias, that gets rather difficult.



        That n should be fine within the double quotes, though.



        In any case, you should probably use a function instead. That way you don't need to think about the extra level of quoting around the commands.



        mycommand() 
        sort






        share|improve this answer













        share|improve this answer



        share|improve this answer











        answered Jun 27 at 21:11









        ilkkachu

        47.3k668130




        47.3k668130












            Popular posts from this blog

            Peggy Mitchell

            Palaiologos

            The Forum (Inglewood, California)