Sponsored Content
Full Discussion: Grep by column-Please help!
Top Forums UNIX for Dummies Questions & Answers Grep by column-Please help! Post 302071450 by bobo on Wednesday 19th of April 2006 04:21:03 PM
Old 04-19-2006
Data Problems!

This syntax works great:

awk -F, '{ if ($6 == 52) print $0 }' input.txt

But I do have problems:

The data i have is SEPERATE by a ; not ,....Please have with this minor issue.

Thanks!
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Grep by column number

I have a data file that is arranged like this: Marketing Ranjit Singh Eagles Dean Johnson FULL Marketing Ken Whillans Eagles Karen Thompson FULL Sales Peter RobertsonGolden TigersRich Gardener PART President Sandeep Jain Wimps Ken Whillans CONT... (7 Replies)
Discussion started by: hitman247m
7 Replies

2. Shell Programming and Scripting

Column grep

hi everyone, I am looking for an easy way to extract columns from a text file based on a regular expression, kind of like grep but searching and returning columns instead. for example, suppose i have the following file, 'file.txt': A B C D B 1 2 3 4 5 6 7 8 9 0 5 6 7 8 9 2 3 8 9 0 I... (6 Replies)
Discussion started by: css136
6 Replies

3. Shell Programming and Scripting

Grep but ignore first column

Hi, I need to perform a grep from a file, but ignore any results from the first column. For simplicity I have changed the actual data, but for arguments sake, I have a file that reads: MONACO Monaco ASMonaco MANUTD ManUtd ManchesterUnited NEWCAS NewcastleUnited NAC000 NAC ... (5 Replies)
Discussion started by: danhodges99
5 Replies

4. Shell Programming and Scripting

Grep 5 biggest column

please help, file1.txt id,week,ict,outgoing_call,blackberry_problem,gprs_problem,sms_problem,flash_problem,sinyal_lemah,blankspot,incoming_call,mms_problem,kualitas_suara,drop_call,data_probl em,cross_connect,connect_no_voice,vas_problem ,1,sumbagsel,96,127,52,70,28,29,21,18,18,8,5,3,0,0,3... (1 Reply)
Discussion started by: radius
1 Replies

5. Shell Programming and Scripting

How to awk or grep the last column in file when date on column contains spaces?

Hi have a large spreadsheet which has 4 columns APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96085 Corp IT Desktop and Apps APM00111803814 server_2 96034 Storage Mgmt Team APM00111803814 server_2 96152 GWP... (6 Replies)
Discussion started by: kieranfoley
6 Replies

6. UNIX for Dummies Questions & Answers

Grep -v value in 2nd column

Trying to do a grep -v on a value in the 2nd column of text. So if the word apple appears in a line in the 2nd column, it would not show up when the file was cat. Seems like a simple enough operation but I just can't figure it out. Any help would be appreciated. Thanks in advance. Are apples... (4 Replies)
Discussion started by: jimmyf
4 Replies

7. Shell Programming and Scripting

How to grep from the third column?

PROL\tests_li004_developers:VAS:3543346:q34243,d3hs35,34bdf3,24sfgg,a3s234 Im trying to grep all text after VAS:3543346, so im trying to just have this q34243,d3hs35,34bdf3,24sfgg,a3s234 Im confused on how I would do this (7 Replies)
Discussion started by: ajetangay
7 Replies

8. Shell Programming and Scripting

Can grep a specific column?

Hello All I have an input file with data below. I would like to grep and display the data where 3rd column contains string or at least one character. Kindly please help me with this! Input: tjfa3|zznpou|224fdd.34.ff3.35 |Tiv|Otj|1 fgduul7|zznikj| ... (7 Replies)
Discussion started by: DoveLu
7 Replies

9. UNIX for Beginners Questions & Answers

Grep A Column Based On Column Name

I have a file with two columns separated by white space. Dog Cat fido sneaky dopey poptart ears whisker barky herd Trying to list the words under the column named Dog. Tried a few variations of awk but can't... (4 Replies)
Discussion started by: jimmyf
4 Replies

10. Shell Programming and Scripting

Grep values from column 2 in reference of column 1

Gents Is it possible to update the code to get the desired output files from the input list. I called variable to the first column. I need to consider the first column as key to grep the values in the second column according to the desired request. input list (attached ) output1 ... (12 Replies)
Discussion started by: jiam912
12 Replies
XML::Smart::FAQ(3pm)					User Contributed Perl Documentation				      XML::Smart::FAQ(3pm)

NAME
XML::Smart::FAQ - Frequently Asked Questions about XML::Smart. SYNOPSIS
This is the Frequently Asked Questions list for XML::Smart. QUESTIONS
For new questions send an e-mail to the author, but please, read first all the F.A.Q. Do I need to install XML::Parser to can use XML::Smart? No! XML::Smart already comes with 2 independent parsers, XML::Smart::Parser and XML::Smart::HTMLParser. If XML::Parser is found XML::Smart will use it by default, and the 2nd options will be XML::Smart::Parser. Note that for complex parsing XML::Parser is recommended, but XML::Smart::Parser will work fine too. What is the best version of XML::Smart to install? Is always the last! Always take a look for new versions before aks for help on XML::Smart. Note that internally XML::Smart is complex, since the main idea of it is to remove the complexity from the hand of the programmer. Actually the idea is to enable the Perl programmer to use and create XML data without really know the XML format. Where can I learn about XML? http://www.xml.com How to apply a DTD to a XML::Smart object tree? Take a look in the method apply_dtd(). Example of use: $xml->apply_dtd(q` <!DOCTYPE cds [ <!ELEMENT cds (album+)> <!ATTLIST cds creator CDATA date CDATA #REQUIRED > <!ELEMENT album (artist , tracks+)> <!ELEMENT artist (#PCDATA)> <!ELEMENT tracks (#PCDATA)> ]> `); This will format automatically elements, attributes, etc... How XML::Smart works? To create XML::Smart, first I have created the module Object::MultiType. With it you can have an object that works at the same time as a HASH, ARRAY, SCALAR, CODE & GLOB. So you can do things like this with the same object: $obj = Object::MultiType->new() ; $obj->{key} ; $obj->[0] ; $obj->method ; @l = @{$obj} ; %h = %{$obj} ; &$obj(args) ; print $obj "send data " ; Seems to be crazy, and can be more if you use tie() inside it, and this is what XML::Smart does. For XML::Smart, the access in the Hash and Array way paste through tie(). In other words, you have a tied HASH and tied ARRAY inside it. This tied Hash and Array work together, soo you can access a Hash key as the index 0 of an Array, or access an index 0 as the Hash key: %hash = ( key => ['a','b','c'] ) ; $hash->{key} ## return $hash{key}[0] $hash->{key}[0] ## return $hash{key}[0] $hash->{key}[1] ## return $hash{key}[1] ## Inverse: %hash = ( key => 'a' ) ; $hash->{key} ## return $hash{key} $hash->{key}[0] ## return $hash{key} $hash->{key}[1] ## return undef The best thing of this new resource is to avoid wrong access to the data and warnings when you try to access a Hash having an Array (and the inverse). Thing that generally make the script die(). Once having an easy access to the data, you can use the same resource to create data! For example: ## Previous data: <hosts> <server address="192.168.2.100" os="linux" type="conectiva" version="9.0"/> </hosts> ## Now you have {address} as a normal key with a string inside: $XML->{hosts}{server}{address} ## And to add a new address, the key {address} need to be an ARRAY ref! ## So, XML::Smart make the convertion: ;-P $XML->{hosts}{server}{address}[1] = '192.168.2.101' ; ## Adding to a list that you don't know the size: push(@{$XML->{hosts}{server}{address}} , '192.168.2.102') ; ## The data now: <hosts> <server os="linux" type="conectiva" version="9.0"/> <address>192.168.2.100</address> <address>192.168.2.101</address> <address>192.168.2.102</address> </server> </hosts> Than after changing your XML tree using the Hash and Array resources you just get the data remade (through the Hash tree inside the object): my $xmldata = $XML->data ; But note that XML::Smart always return an object! Even when you get a final key. So this actually returns another object, pointhing (inside it) to the key: $addr = $XML->{hosts}{server}{address}[0] ; ## Since $addr is an object you can TRY to access more data: $addr->{foo}{bar} ; ## This doens't make warnings! just return UNDEF. ## But you can use it like a normal SCALAR too: print "$addr " ; $addr .= ':80' ; ## After this $addr isn't an object any more, just a SCALAR! When I generate the XML data new lines ( ) are added to the content! You should use the options for the method data() and save() to not add identation to the generated data: $XML->data( noident => 1 ) ; ## or better: $XML->data( nospace => 1 ) ; Your question is not here? Just send me an e-mail. ;-P AUTHOR
Graciliano M. P. <gm@virtuasites.com.br> I will appreciate any type of feedback (include your opinions and/or suggestions). ;-P Enjoy and thanks for who are enjoying this tool and have sent e-mails! ;-P ePod This document was written in ePod (easy-POD), than converted to POD, and from here you know the way. perl v5.10.1 2004-12-08 XML::Smart::FAQ(3pm)
All times are GMT -4. The time now is 02:09 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy