[prev in list] [next in list] [prev in thread] [next in thread] 

List:       centos
Subject:    Re: [CentOS] Echoing statements in bash script
From:       H <agents () meddatainc ! com>
Date:       2022-01-16 1:48:58
Message-ID: c5561124-cc30-140d-7220-da4eeb5a8e25 () meddatainc ! com
[Download RAW message or body]

On 01/14/2022 08:59 PM, Gordon Messmer wrote:
> 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: \
> https://www.oreilly.com/library/view/bash-cookbook/0596526784/ch03s04.html 
> So, maybe:
> 
> f () {
> cat > file.txt <<-'EOF'
> # this is a test
> a=123
> b=456
> EOF
> }
> 
> 
> (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
> CentOS@centos.org
> https://lists.centos.org/mailman/listinfo/centos

Thank you, will try that. I use Geany as my editor and for some reason it changes all \
tabs to spaces when I edit a bash script... Not sure why?

_______________________________________________
CentOS mailing list
CentOS@centos.org
https://lists.centos.org/mailman/listinfo/centos


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic