Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   Grep for colums? (http://www.linux-archive.org/debian-user/243741-grep-colums.html)

Nagy Daniel 02-11-2009 10:09 AM

Grep for colums?
 
Is there a methodfor searching in colums just like grep does in rows, but i don't know how many colums I will have, so: awk is not good, beacuse awk {print $1$2$3} it's not a good soultion:S i have too many colums

Nagy Daniel 02-11-2009 10:26 AM

Grep for colums?
 
the "text" is here:

http://pastebin.com/f37214a30

and I only want this string:

http://downloads.sourceforge.net/portableapps/nvu_portable_1.0_rev_5_en-us.paf.exe?download

so I want to search like:| grep downloads.sourceforge.net | grep nvu
but the text isn't separated with enters, and I want to search in columns, not in rows :S

2009/2/11 Γιώργος *άλλας <gpall@ccf.auth.gr>

Nagy Daniel wrote:




Is there a methodfor searching in colums just like grep does in rows, but i don't know how many colums I will have, so: awk is not good, beacuse awk {print $1$2$3} it's not a good soultion:S i have too many colums







There is always perl!



If you send an example of what you want, I can hack you quickly a 5 line perl script to do the job...



G.

Johann Spies 02-11-2009 11:34 AM

Grep for colums?
 
On Wed, Feb 11, 2009 at 12:26:07PM +0100, Nagy Daniel wrote:
> the "text" is here:
>
> http://pastebin.com/f37214a30

I have copied that into a file /tmp/w

>
> and I only want this string:
>
> http://downloads.sourceforge.net/portableapps/
> nvu_portable_1.0_rev_5_en-us.paf.exe?download

% grep -o 'nvu_portable_1.0_rev_5_en-us.paf.exe?download' /tmp/w
nvu_portable_1.0_rev_5_en-us.paf.exe?download


Regards
Johann

--
Johann Spies Telefoon: 021-808 4036
Informasietegnologie, Universiteit van Stellenbosch

"Make a joyful noise unto the LORD, all ye lands.
Serve the LORD with gladness: come before his presence
with singing. Know ye that the LORD he is God: it is
he that hath made us, and not we ourselves; we are his
people, and the sheep of his pasture."
Psalms 100:1-3


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Paul E Condon 02-11-2009 03:25 PM

Grep for colums?
 
On 2009-02-11_12:09:20, Nagy Daniel wrote:
> Is there a methodfor searching in colums just like grep does in rows, but i
> don't know how many colums I will have, so: awk is not good, beacuse awk
> {print $1$2$3} it's not a good soultion:S i have too many colums

Yes, and its call SQL. If you only want to do one or two searches, you
can use perl, or awk, coreutils, etc., but if getting accurate and
reproducible results is important to you, you will need some serious
computational machinery.

Also, in awk, use {print $1, $2, $3 ;} to keep the space delimiter
between columns. And learn about the built-in variable NF. Its value
is always set to the number of fields (columns) in the current line.

HTH

--
Paul E Condon
pecondon@mesanetworks.net


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Michael Iatrou 02-11-2009 05:11 PM

Grep for colums?
 
When the date was Wednesday 11 February 2009, Nagy Daniel wrote:

> the "text" is here:
>
> http://pastebin.com/f37214a30
>
> and I only want this string:
>
> http://downloads.sourceforge.net/portableapps/nvu_portable_1.0_rev_5_en-u
>s.paf.exe?download

It seems to me that you only want to grab urls. This should (kind of) do the
trick:

cat f37214a30.txt | perl -ne 'print "$1
" if (/href="(.+?)"/ig)'

f37214a30.txt is a file with the snippet you uploaded.

--
Μιχάλης Ιατρού (tljw)


--
To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

Nagy Daniel 02-11-2009 10:42 PM

Grep for colums?
 
Thank you!!!

The solution was this:




cat text.txt | perl -ne 'print "$1
" while (/href="" | grep sourceforge | grep nvu




2009/2/11 Michael Iatrou <m.iatrou@freemail.gr>

When the date was Wednesday 11 February 2009, Nagy Daniel wrote:



> the "text" is here:

>

> http://pastebin.com/f37214a30

>

> and I only want this string:

>

> http://downloads.sourceforge.net/portableapps/nvu_portable_1.0_rev_5_en-u

>s.paf.exe?download



It seems to me that you only want to grab urls. This should (kind of) do the

trick:



cat f37214a30.txt | perl -ne 'print "$1
" if (/href="">


f37214a30.txt is a file with the snippet you uploaded.



--

*Μιχάλης Ιατρού (tljw)





--

To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org

with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org


All times are GMT. The time now is 03:07 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.