Re: Echoing statements in bash script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

On 1/14/22 17:18, H wrote:
Using a bash script I want to echo several strings to a file. The echo statement, however, is in a function and thus indented but I do /not/ want the strings echoed indented in the new file. Is this doable?

I don't think you can do that for strings passed as arguments, but you can do that with strings that are here-documents:

So, maybe:

f () {
    cat > file.txt <<-'EOF'
    # this is a test

(Note that those lines need to be indented with tabs.  None of my email editors will compose in plain text at the moment, oddly, so those are being converted to spaces)

CentOS mailing list

[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]

  Powered by Linux