What are the differences between here document and here string in their purposes? [on hold]

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











up vote
2
down vote

favorite
1












In bash, it seems to me both here document and here string can be used for providing strings as stdin inputs. here document may provide an extra features to specify delimiter, which I am not sure if is necessary in any case.



What are the differences between their purposes? Can one always be used wherever the other is used? When shall we use which? Thanks.










share|improve this question













put on hold as primarily opinion-based by Kusalananda, G-Man, Isaac, X Tian, mosvy 2 days ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
    – Kusalananda
    Nov 18 at 16:21














up vote
2
down vote

favorite
1












In bash, it seems to me both here document and here string can be used for providing strings as stdin inputs. here document may provide an extra features to specify delimiter, which I am not sure if is necessary in any case.



What are the differences between their purposes? Can one always be used wherever the other is used? When shall we use which? Thanks.










share|improve this question













put on hold as primarily opinion-based by Kusalananda, G-Man, Isaac, X Tian, mosvy 2 days ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.










  • 4




    Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
    – Kusalananda
    Nov 18 at 16:21












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





In bash, it seems to me both here document and here string can be used for providing strings as stdin inputs. here document may provide an extra features to specify delimiter, which I am not sure if is necessary in any case.



What are the differences between their purposes? Can one always be used wherever the other is used? When shall we use which? Thanks.










share|improve this question













In bash, it seems to me both here document and here string can be used for providing strings as stdin inputs. here document may provide an extra features to specify delimiter, which I am not sure if is necessary in any case.



What are the differences between their purposes? Can one always be used wherever the other is used? When shall we use which? Thanks.







bash io-redirection here-document here-string






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 at 13:32









Tim

1




1




put on hold as primarily opinion-based by Kusalananda, G-Man, Isaac, X Tian, mosvy 2 days ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.






put on hold as primarily opinion-based by Kusalananda, G-Man, Isaac, X Tian, mosvy 2 days ago


Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
    – Kusalananda
    Nov 18 at 16:21












  • 4




    Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
    – Kusalananda
    Nov 18 at 16:21







4




4




Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
– Kusalananda
Nov 18 at 16:21




Use here-strings all the time if you wish, until you encounter a situation where it's not possible. Then use a here-document. Or use temporary files, always, and never ever touch here-strings nor here-documents. Deciding when to use what is something you as a developer has to do.
– Kusalananda
Nov 18 at 16:21










1 Answer
1






active

oldest

votes

















up vote
6
down vote













Here string is for shorter strings, here document for longer ones. The extra feature of here documents is that you can pass arbitrary text without having to worry about quoting. Just single-quote the delimiter, and make sure it does not show up in the text. You may use a random string (drawing from characters and digits), a technique that is also used to delimit parts in MIME encoded email.






share|improve this answer



























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    6
    down vote













    Here string is for shorter strings, here document for longer ones. The extra feature of here documents is that you can pass arbitrary text without having to worry about quoting. Just single-quote the delimiter, and make sure it does not show up in the text. You may use a random string (drawing from characters and digits), a technique that is also used to delimit parts in MIME encoded email.






    share|improve this answer
























      up vote
      6
      down vote













      Here string is for shorter strings, here document for longer ones. The extra feature of here documents is that you can pass arbitrary text without having to worry about quoting. Just single-quote the delimiter, and make sure it does not show up in the text. You may use a random string (drawing from characters and digits), a technique that is also used to delimit parts in MIME encoded email.






      share|improve this answer






















        up vote
        6
        down vote










        up vote
        6
        down vote









        Here string is for shorter strings, here document for longer ones. The extra feature of here documents is that you can pass arbitrary text without having to worry about quoting. Just single-quote the delimiter, and make sure it does not show up in the text. You may use a random string (drawing from characters and digits), a technique that is also used to delimit parts in MIME encoded email.






        share|improve this answer












        Here string is for shorter strings, here document for longer ones. The extra feature of here documents is that you can pass arbitrary text without having to worry about quoting. Just single-quote the delimiter, and make sure it does not show up in the text. You may use a random string (drawing from characters and digits), a technique that is also used to delimit parts in MIME encoded email.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 18 at 15:16









        stefan

        500312




        500312












            Popular posts from this blog

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

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?