append with eof

Mike Ballon mike.ballon at gmail.com
Wed Mar 11 10:59:35 MST 2015


Sorry, rough afternoon yesterday...

cat reads then writes to stdout

If you're using echo, in the sense we're discussing, it will never even see
the stdin you're attempting to send. To test run the following and you'll
see the test file contains the echo'd 1

$ echo "1" > test << EOF
> 2
> EOF
$ cat test
1

Another way to see this would be:

$ > test << EOF | echo 1
> EOF
1
$ cat test
[nothing returned]

Another:

$ echo > test << EOF
> 1
> 2
> EOF
$ cat test
[nothing returned]

You can do this:

$ echo 1 > test
$ cat test
1

It takes a while to grasp, believe me. Sometimes I'll type something out
and go, "huh, why didn't that work". Then I look at it, "doh!".

read read read



On Tue, Mar 10, 2015 at 1:45 PM, Michael Havens <bmike1 at gmail.com> wrote:

> why would it not work with echo?
>
> :-)~MIKE~(-:
>
> On Tue, Mar 10, 2015 at 7:53 AM, Mike Ballon <mike.ballon at gmail.com>
> wrote:
>
>> First, if you're just trying to backup conf files, then simply make a
>> backup of the conf file and restore it when needed.
>>
>> To answer your question, yes, specifically with the cat command, this
>> won't work with echo. You can test this on your own and t
>>
>> $ cat > test << EOF
>> > 1
>> > 2
>> > 3
>> > EOF
>> $ cat test
>> 1
>> 2
>> 3
>> $ cat >> test << EOF
>> > 4
>> > EOF
>> $ cat test
>> 1
>> 2
>> 3
>> 4
>>
>> You can also start with an append if you wish:
>>
>> $ cat >> test << EOF
>> > 1
>> > 2
>> > EOF
>> $ cat test
>> 1
>> 2
>>
>> http://www.linuxjournal.com/content/working-stdin-and-stdout
>>
>>
>> On Mon, Mar 9, 2015 at 11:51 PM, Michael Havens <bmike1 at gmail.com> wrote:
>>
>>> do you think this would have the desired effect?
>>>
>>>
>>> sudo cat >> /etc/apt/apt.conf  << eof
>>> Acquire::Queue-Mode "host";
>>> eof
>>>
>>> sudo cat >> /etc/sysctl.conf << eof
>>> #
>>> # Reduce the swap tendency
>>> vm.swappiness = 10
>>> eof
>>>
>>> sudo cat >> /etc/apache2/apache2.conf << eof
>>> Include /etc/phpmyadmin/apache.conf
>>> eof
>>>
>>> sudo cat >> /etc/fstab << eof
>>> /media/bmike1/entertainment/Pictures /home/bmike1/Pictures none bind 0 0
>>> eof
>>>
>>> would the single line appendages just need the blank line?
>>>
>>> :-)~MIKE~(-:
>>>
>>> On Mon, Mar 9, 2015 at 8:41 PM, Michael Havens <bmike1 at gmail.com> wrote:
>>>
>>>> Okay now, I learned just today how >> works and I want to update all of
>>>> my reinstall scripts so all I need to do is copy-n-paste into a terminal
>>>> and everything will be done. Learned when I was doing Linux from scratch
>>>>  that to create a file of multiple lines without starting an editor you do:
>>>>
>>>> *cat > filename << "EOF"
>>>> *contents
>>>>
>>>> *of*
>>>>
>>>> *file*
>>>>
>>>> *EOF*
>>>>
>>>>  Oh.... I think I get it. just turn the '>' into '>>'
>>>> am I correct?
>>>>
>>>> :-)~MIKE~(-:
>>>>
>>>
>>>
>>> ---------------------------------------------------
>>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>>> To subscribe, unsubscribe, or to change your mail settings:
>>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>>
>>
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>
>
> ---------------------------------------------------
> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
> To subscribe, unsubscribe, or to change your mail settings:
> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phxlinux.org/pipermail/plug-discuss/attachments/20150311/904bc338/attachment.html>


More information about the PLUG-discuss mailing list