Code Comments
Programming Forum and web based access to our favorite programming groups.I am having a little problem running a simple awk command.
I need the entire string output twice, but when I try
c:\>dir /b | gawk '{print $0 " " $0}'
if only get one output item
This is using cygwin's gawk on a windows box ( excuse the 'w' word )
Post Follow-up to this messageJanis,
thanks but this also does not work.
this is a simple example of what is happening:
C:\BIN>echo one two | gawk '{print $1 " " $2}'
one two
C:\BIN>echo one two | gawk '{print $1 " " $1}'
one one
C:\BIN>echo one two | gawk '{print $0 " " $0}'
one two
the last command I would expect to be:
one two one two
Post Follow-up to this messageI have always had success with the quotes I used. But just to give it a
try:
c:\>echo one two | gawk "{print $0 ' ' $0}"
gawk: {print $0 ' ' $0}
gawk: ^ invalid char ''' in expression
so here is some other output
c:\>echo one two | gawk '{print $0" some stuff " $0}'
some stuff one two
c:\>echo one two | gawk '{print $1" some stuff " $1}'
one some stuff one
c:\>echo one two | gawk '{print $1" some stuff " $2}'
one some stuff two
now the next 2 are a little interesting
c:\>echo one two | gawk '{print $0 " some stuff"}'
some stuff
c:\>echo one two | gawk '{print " some stuff " $0}'
some stuff one two
oh well just one of those windows thingies
works fine on linux ( no surprise there )
Post Follow-up to this message
coltrane wrote:
> I have always had success with the quotes I used. But just to give it a
> try:
>
> c:\>echo one two | gawk "{print $0 ' ' $0}"
> gawk: {print $0 ' ' $0}
> gawk: ^ invalid char ''' in expression
> c:\>echo one two | gawk '{print $0" some stuff " $0}'
> some stuff one two
>
> c:\>echo one two | gawk '{print $1" some stuff " $1}'
> one some stuff one
>
> c:\>echo one two | gawk '{print $1" some stuff " $2}'
> one some stuff two
> c:\>echo one two | gawk '{print $0 " some stuff"}'
> some stuff
>
> c:\>echo one two | gawk '{print " some stuff " $0}'
> some stuff one two
Will you PLEASE just do what Janis suggested days ago instead of
repeating all this nonsense that obviously will not work!!!!!
Ed.
Post Follow-up to this messageLe Fri, 22 Apr 2005 04:53:09 -0700, coltrane a écrit_:
> Janis,
> thanks but this also does not work.
>
> this is a simple example of what is happening:
>
>
> C:\BIN>echo one two | gawk '{print $1 " " $2}'
> one two
>
> C:\BIN>echo one two | gawk '{print $1 " " $1}'
> one one
>
> C:\BIN>echo one two | gawk '{print $0 " " $0}'
> one two
>
> the last command I would expect to be:
> one two one two
It should :-)
Try without the spaces maybe ?
$ echo one two | gawk '{print $0" "$0}'
Post Follow-up to this messageOn 21 Apr 2005 13:52:59 -0700, coltrane
<tendengarci@yahoo.com> wrote:
> I am having a little problem running a simple awk command.
>
> I need the entire string output twice, but when I try
>
> c:\>dir /b | gawk '{print $0 " " $0}'
>
I bet it's that darn CRLF thing again.
In other words, you are only seeing $0 one time because gawk is printing
$0\r" "$0
dir /b | gawk '{sub(/\r/,""); print $0 " " $0}'
--
Chisolm's First Corollary to Murphy's Second Law:
When things just can't possibly get any worse, they will.
Post Follow-up to this messageOn 22 Apr 2005 10:09:54 -0700, coltrane
<tendengarci@yahoo.com> wrote:
> I have always had success with the quotes I used. But just to give it a
> try:
>
> c:\>echo one two | gawk "{print $0 ' ' $0}"
> gawk: {print $0 ' ' $0}
> gawk: ^ invalid char ''' in expression
>
echo one two | gawk "{print $0 \" \" $0}"
--
Chisolm's First Corollary to Murphy's Second Law:
When things just can't possibly get any worse, they will.
Post Follow-up to this messageOn Fri, 22 Apr 2005 01:53:45 GMT, gazelle@yin.interaccess.com (Kenny McCormack) wrote: >In article <1gkg61dca5urfgnc3kh3s627sb5ab50pe0@4ax.com>, >Ted Davis <tdavis@gearbox.maem.umr.edu> wrote: > ^^^^ > >What do you mean by "true" in this context? Compiled with a Windows compiler, perhaps with specific modifications for use in the Windows console environment. The Cygwin version is intended for use in the Cygwin environment though it does seem to work in the pure Windows environment (Cygwin is installed and configured for DOS style files). I seem to remember that they fail differently when asked to do Unix specific things like bidirectional pipes and direct read/write to TCP/IP, though they both fail. -- T.E.D. (tdavis@gearbox.maem.umr.edu) SPAM filter: Messages to this address *must* contain "T.E.D." somewhere in the body or they will be automatically rejected.
Post Follow-up to this messageLe Fri, 22 Apr 2005 04:53:09 -0700, coltrane a écrit_:
> Janis,
> thanks but this also does not work.
>
> this is a simple example of what is happening:
>
>
> C:\BIN>echo one two | gawk '{print $1 " " $2}'
> one two
>
> C:\BIN>echo one two | gawk '{print $1 " " $1}'
> one one
>
> C:\BIN>echo one two | gawk '{print $0 " " $0}'
> one two
>
> the last command I would expect to be:
> one two one two
It should :-)
Try without the spaces maybe ?
$ echo one two | gawk '{print $0" "$0}'
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.