make
Michael Havens
bmike1 at gmail.com
Mon Aug 25 12:24:55 MST 2014
you guys are so helpful! Thanks.
:-)~MIKE~(-:
On Sun, Aug 24, 2014 at 7:40 PM, Jon Kettenhofen <subs at kexsof.com> wrote:
> I like visible proofs, so here's a test I ran:
> (terminal output was as is shown)
>
> [jon at localhost ~]$ rm temp
> [jon at localhost ~]$ echo >>temp
> [jon at localhost ~]$ echo $?
> 0
> [jon at localhost ~]$ cat temp
>
> [jon at localhost ~]$ echo >>temp 2>&1
> [jon at localhost ~]$ echo $?
> 0
> [jon at localhost ~]$ cat temp
>
>
> [jon at localhost ~]$
>
> as you can see, no errors and the single ">" did not erase the file when
> used in this manner. So Mike's script should work as intended
> at least if there is no stderr output.
>
> but suppose there was an error? (apologizing for the length of ...)
>
> [jon at localhost ~]$ echo "echo" >test
> [jon at localhost ~]$ echo "ls temp2" >>test
> [jon at localhost ~]$ # test ls of non-existent file
> [jon at localhost ~]$ ls temp2
> ls: cannot access temp2: No such file or directory
> [jon at localhost ~]$ echo $?
> 2
> [jon at localhost ~]$ # see, we get both an error and stderr message
> [jon at localhost ~]$ # so
> [jon at localhost ~]$ mv test test.sh
> [jon at localhost ~]$ chgmod +x test.sh
> bash: chgmod: command not found...
> [jon at localhost ~]$ chmod +x test.sh
> [jon at localhost ~]$ # i'm not perfect!
> [jon at localhost ~]$ rm temp
> [jon at localhost ~]$ ./test.sh >>temp
> ls: cannot access temp2: No such file or directory
> [jon at localhost ~]$ echo $?
> 2
> [jon at localhost ~]$ cat temp
>
> [jon at localhost ~]$ ./test.sh >>temp 2>&1
> [jon at localhost ~]$ echo $?
> 2
> [jon at localhost ~]$ cat temp
>
>
> ls: cannot access temp2: No such file or directory
> [jon at localhost ~]$
>
> as you can see, Mike's script will work as he apparently intended,
> providing he's using a modern version of bash.
>
>
>
> On 08/24/2014 09:56 PM, James Mcphee wrote:
>
>> you've said make, append stdout (default file descriptor 1) to file
>> make.fail, assign stderr (default filedescriptor 2) the same
>> filedescriptor as stdout. So... If the intent was to have both stderr
>> and stdout append make.fail, then it is correct.
>>
>>
>> On Sun, Aug 24, 2014 at 6:06 PM, Michael Havens <bmike1 at gmail.com
>> <mailto:bmike1 at gmail.com>> wrote:
>>
>> what I really need to know is will this:
>>
>> make>>make.fail 2>&1
>>
>> send stderr and stdout to the file 'make.fail' or did I write it
>> incorrectly?
>>
>> :-)~MIKE~(-:
>>
>>
>> On Sun, Aug 24, 2014 at 2:56 PM, Brian Cluff <brian at snaptek.com
>> <mailto:brian at snaptek.com>> wrote:
>>
>> the > will delete any file that it points at even if the command
>> doesn't actually output anything. It will even delete the file
>> is the command doesn't exist like if you type grep as gerp
>> >file, file will still be created/overwritten.
>>
>> If you want to make sure that your command doesn't overwrite any
>> existing files you have to set the noclobber option like:
>> $ set -o noclobber
>>
>> A good trick to know:
>> You can use the > to delete the contents of a file without
>> having to delete and recreate the file by simply doing this:
>> $ >yourfile
>>
>> Brian Cluff
>>
>>
>> On 08/24/2014 02:36 PM, Michael Havens wrote:
>>
>> I have a question about redirections:
>>
>> make>>make.fail 2>&1
>>
>> tells it make and then to send (>) stderr (2) to stdout (1)
>> and also to
>> send stdout that way also (&1). finally all of that gets
>> sent to a file
>> named make.fail (>>). Isn't '>>' actually 'append' whereas
>> '>' would
>> work just as well so long as the file didn't already exist?
>> If the file
>> did exist would I get an error or would the file be
>> overwritten?
>> :-)~MIKE~(-:
>>
>>
>> ------------------------------__---------------------
>> PLUG-discuss mailing list -
>> PLUG-discuss at lists.phxlinux.__org
>> <mailto:PLUG-discuss at lists.phxlinux.org>
>>
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/__mailman/listinfo/plug-discuss
>> <http://lists.phxlinux.org/mailman/listinfo/plug-discuss>
>>
>> ------------------------------__---------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.__org
>> <mailto:PLUG-discuss at lists.phxlinux.org>
>>
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/__mailman/listinfo/plug-discuss
>>
>> <http://lists.phxlinux.org/mailman/listinfo/plug-discuss>
>>
>>
>>
>> ---------------------------------------------------
>> PLUG-discuss mailing list - PLUG-discuss at lists.phxlinux.org
>> <mailto:PLUG-discuss at lists.phxlinux.org>
>>
>> To subscribe, unsubscribe, or to change your mail settings:
>> http://lists.phxlinux.org/mailman/listinfo/plug-discuss
>>
>>
>>
>>
>> --
>> James McPhee
>> jmcphe at gmail.com <mailto:jmcphe at gmail.com>
>>
>>
>>
>> ---------------------------------------------------
>> 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/20140825/4737ff73/attachment.html>
More information about the PLUG-discuss
mailing list