Re: gawk

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

 



On Wed, May 16, 2018 at 02:43:09PM -0700, Rick Stevens wrote:
> On 05/16/2018 02:11 PM, Samuel Sieb wrote:
> > On 05/16/2018 02:05 PM, Patrick Dupre wrote:
> >> This is correct, but
> >> if I do:
> >>       print "#" > "tmptmp.txt" ;
> >> after
> >> print $1 $2 > "tmptmp.txt" ;
> >>
> >> then I get ^M
> >> in my file
> >> I do not have the ^M  if I only make print $1 $2 > "tmptmp.txt" ;
> >> and never make a print "#"
> >>
> >> Can I avoid these ^M
> >> ?
> > 
> > This really isn't the right place for this kind of question, but at
> > least provide a full example of what you're trying to do.  You aren't
> > providing enough info to get a useful response.
> 
> I agree with Sam that you aren't providing enough info. I think
> you're saying you're essentially doing (in gawk):
> 
> 	print $1 $2 > "tmptmp.txt";
> 	print "#" > "tmptmp.txt";

True in shell, not in awk.  If the file names match,
only the first encountered '>' overwrites the file.
The ">>" is needed to avoid overwriting a file that
exists at the start of the program (like a logfile).

> 
> And ending up with a "^M" in your file. First off, the second line
> would overwrite anything you did in the first line (you need to use a
> ">>" to APPEND data to an existing file...just like in the shell), and
> the "^M" probably indicates a carriage return in the file. If you
> changed the ORS (output record separator) to a carriage return from it's
> default value of newline, that's what you'd get.
> 

I just noted the output file name with a ".txt" extension.
Might gawk assume this is a "windows text file" and add
a \r instead of \n?

Try a different output file name.

> Patrick, this isn't the first time (or second or third) you've posted
> a question with absolutely no context about what you're trying to do.
> If you want help, you HAVE to tell us what you're trying to accomplish.

-- 
Jon H. LaBadie                  jonfu@xxxxxxxxxx
_______________________________________________
users mailing list -- users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe send an email to users-leave@xxxxxxxxxxxxxxxxxxxxxxx



[Index of Archives]     [Older Fedora Users]     [Fedora Announce]     [Fedora Package Announce]     [EPEL Announce]     [EPEL Devel]     [Fedora Magazine]     [Fedora Summer Coding]     [Fedora Laptop]     [Fedora Cloud]     [Fedora Advisory Board]     [Fedora Education]     [Fedora Security]     [Fedora Scitech]     [Fedora Robotics]     [Fedora Infrastructure]     [Fedora Websites]     [Anaconda Devel]     [Fedora Devel Java]     [Fedora Desktop]     [Fedora Fonts]     [Fedora Marketing]     [Fedora Management Tools]     [Fedora Mentors]     [Fedora Package Review]     [Fedora R Devel]     [Fedora PHP Devel]     [Kickstart]     [Fedora Music]     [Fedora Packaging]     [Fedora SELinux]     [Fedora Legal]     [Fedora Kernel]     [Fedora OCaml]     [Coolkey]     [Virtualization Tools]     [ET Management Tools]     [Yum Users]     [Yosemite News]     [Gnome Users]     [KDE Users]     [Fedora Art]     [Fedora Docs]     [Fedora Sparc]     [Libvirt Users]     [Fedora ARM]

  Powered by Linux