Grep for colums?
Hi,
martin@localhost:~/2delete$ cat columns.txt 1 2 3 a b c 1 2 3 4 a b c d martin@localhost:~/2delete$ awk '$2 == "b"' columns.txt a b c a b c d martin@localhost:~/2delete$ awk '$2 == "2"' columns.txt 1 2 3 1 2 3 4 2009/2/11 Nagy Daniel <n.dani86@gmail.com>: > 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 hmm I don't quite see the problem -- http://soup.alt.delete.co.at http://www.xing.com/profile/Martin_Marcher http://www.linkedin.com/in/martinmarcher You are not free to read this message, by doing so, you have violated my licence and are required to urinate publicly. Thank you. Please avoid sending me Word or PowerPoint attachments. See http://www.gnu.org/philosophy/no-word-attachments.html -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
Grep for colums?
Nagy Daniel <n.dani86@gmail.com> wrote:
> cat text.txt | perl -ne 'print "$1 " while (/href="(.+?)"/ig)' | grep > sourceforge | grep nvu You don't need cat for a single file! perl -ne 'print "$1 " while (/href="(.+?)"/ig)' text.txt | grep sourceforge | grep nvu Or, by using perl in a single command, perl -ne 'while (($m) = /href="(.+?)"/ig && $m =~ /sourceforge/ && $m =~ /nvu/) { print "$m " }' text.txt Chris -- To UNSUBSCRIBE, email to debian-user-REQUEST@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org |
Grep for colums?
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-us.paf.exe?download > > so I want to search like: > | grep downloads.sourceforge.net <http://downloads.sourceforge.net> | > grep nvu > but the text isn't separated with enters, and I want to search in > columns, not in rows :S > Although there are already given very nice perl solutions, with awk an answer for what you asked for is awk '{i = 0; while (i++ < NF) {if ($i ~ /downloads.sourceforge.net.*nvu/) print $i}}' test-text.txt -- Regards, Jörg-Volker. -- 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 05:40 PM. |
VBulletin, Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.