Programming :: Perl Extract Information For A Particular Column?

Oct 24, 2010

I have a file which has the output as shown below:

Code:

Teams | matches |Goals | YC | RC
------------------------------------------------------------------------------
Liverpool: | | | |
Gerrard | 97 | 100 | 41665 | 1342

[code]....

I need to extract the Info from the RC column for the first 4 players of liverpool. The test code i have does the same,but can anyone show me a better way of doing it.I could do it easily with gawk -F"|" and print the respective column,but i need to do this in perl.

Code:

#!/usr/bin/perl
use strict;
use warnings;

[code]....

View 7 Replies


ADVERTISEMENT

Programming :: Extract Dwarf Information Debug A Section?

May 10, 2011

I would like to extract debug information but I have some problems. For example, I have a executable a.out...

Quote:

nm -f sysv a.out | grep ".global_var" >vars.txt

With this command I extract all my variables. All of them are in .global_var section, and it give me follow information:

Quote:

CAN_station_n |08073258| D | OBJECT|00000001| |.global_var
CONTROLend |080732a7| D | OBJECT|00000001| |.global_var

[code]....

Well, I have only address of my vars, but I would like to know type var or struct of the variables. With dwarf dump I have all of information, but it is a mess...

Quote:

<1><117bc>: Abbrev Number: 32 (DW_TAG_variable)
<117bd> DW_AT_name : (indirect string, offset: 0x153d): draw_limits
<117c1> DW_AT_decl_file : 128
<117c2> DW_AT_decl_line : 207

[code]...

Is there any parser or way to put in order this information?? create a file with the follow information:

name of var - address - type - size - struct or not

View 5 Replies View Related

Programming :: Use Perl Regex To Extract The Hostname From A FQDN?

Nov 19, 2010

How do i use perl regex to extract the hostname from a FQDN?

I have

Quote:

$host=ganymede.a.linux.com
$host=io.a.linux.com
$host=europa.a.linux.com

i just want the characters which are to the left of the first .(dot) in FQDN name. I could get it using substr and split function,but how do i get it through regex.

View 13 Replies View Related

Programming :: Perl String Question:extract Lines From Somefile?

Jun 19, 2011

what's the equivalent code of Perl?sed -i 777,2545!d somefileObviously it extract lines of somefile between that 2 digits .

View 1 Replies View Related

Programming :: Create A ZIP In Perl Without Storing Path Information?

Mar 1, 2010

I have the following code snippet:

Code:

my $file = 'test/mybigfile';
my $zip = Archive::Zip->new();
my $zipped = $zip->addFile($file);

[code]....

it simply takes a file (in this case, "mybigfile") and creates a ZIP file containing that file only. Now, my problem is that when I go to decompress the ZIP file, it creates the relative (or absolute, depending on case) path of the original file. To make an example:

Code:

$ pwd
/tmp/perl
$ ls -R

[code]....

What I need is *not* to store the path information inside of the ZIP file, so that once I decompress the ZIP file I only get the original one without having paths created.

View 2 Replies View Related

Programming :: Perl Module For Getting Information From Remote Machines

Oct 16, 2010

I need to get some information like cpu usage,free memory,swap memory and other information from a bunch of remote hosts.Can any one tell me of a good perl module which does that.I dont want to use Net::Rsh or Net:SSH.

View 14 Replies View Related

General :: Unable To Extract Last Column From Awk

May 20, 2011

I have a basic question of awk.

Code:

var=/test/build/create/sls
echo $var | awk '{ FS = ":" ; print $NF }'
/test/build/create/sls

I am trying to extract last column from the above awk one liner.

View 4 Replies View Related

General :: Extract 5th Column From A File Without The Header?

Oct 15, 2010

How can I extract 5th column from a file without the header.

View 5 Replies View Related

General :: Extract One Complete Column From LS Output

Oct 2, 2010

What I need to do is to extract one complete column (file size) from the output of ls -lS but while doing so in some rows I have a single space but in some other rows I have 2 or 3 spaces like some file sizes are different with 30 bytes 400 bytes and some 4000 bytes. So when I extract the output of ls using | cut -d ' ' -f5 i get the value which has only one space i.e. I get 4000 as output because 400 has 2 spaces seperated and 30 is 3 spaces separated. So how to get the file size column from the ls output?

View 10 Replies View Related

Programming :: Awk Multiple Column Into Single Column?

Jul 15, 2010

I have a multicolumn datas, like

a1 b1 ... f1
a2 b2 ... f2
. . ... .

[code]...

I would like to make a file with all these data in one column, like

a1
a2
.
.

[code]....

Can it be done with awk or some other command? Also, is it possible then do add another column in front of this one with numbers of the lines (for every previous column), like

1 a1
2 a2
. .
. .

[code].....

View 14 Replies View Related

Ubuntu :: Using Cut And Grep To Extract Information?

Aug 2, 2011

How would I use cut or grep to take this line :

Code:

Load......................... 198 Watt(22 %)

and make it into this information, in a text file :

Code:

198 Watts

If you don't mind, please explain the process, as I have been trying to figure this command out, and I must be missing something.

View 9 Replies View Related

Ubuntu :: Download A Webpage To Extract Information?

Jun 30, 2011

I want to download a webpage to extract information. This used to work with other pages, but with this particular page [URL].., I get the following error.

Code:
bjvca@ifpri-laptop:~$ wget http://www.farmgainafrica.org/index.php?option=com_content&view=article&id=5&Itemid=27
[1] 10375
[2] 10376
[3] 10377

[Code]...

View 3 Replies View Related

General :: Write A Script To Extract Information From Db Tables?

May 25, 2010

I want to write a script that will extract information from a db table and store that information to a csv file. Basically, I have imported data into a table, I want to save this data to a csv file for later processing. How do I connect to the db and extraxt information from the table?

View 3 Replies View Related

Programming :: Get Min From A Column?

Dec 8, 2010

i am new to scriptingi have a file : file.dat with following data

Code: STORAGE PERCENTAGE FLAG:
/storage_01 64% 0
/storage_02 17% 1

[code]...

View 4 Replies View Related

Programming :: Column Statistic By Awk ?

Jan 13, 2010

Here is the txt file

Code:

I want to use a script to statistic the results like that

I want to know the the same string in the first column and how many different in the second column ?
how awk to write ?

View 7 Replies View Related

Programming :: Postgresql Put '' In Column?

Apr 9, 2010

Problem is simple but I can't figure out how to solve it, I tried any possible way that I know but with no result.I'm using simple perl script with DBI and do select from one table and do update in other table with results from select, but I can't preserve my '' returned from select when doing update. I simply want my '' from first table to be '' in second but postgres makes them real new lines. I tried to escape '' with , '',"",E(I mean E'value here') in front of value that updating but they are always real new lines not '' in new table.

View 2 Replies View Related

Programming :: Bash Awk Column To End Of File?

Sep 4, 2010

Code:

#!/bin/bash
ls -lhGg | while read line; do echo "$line"; done | awk ' { print $3" "$6 } '

what i want to do is be able to print column 3 and every column greater then 5. Has to be to the end of the line, since different filenames can have different amounts of words in them and the blank space is the separator. my current code works just fine if the file has no blank space.

View 8 Replies View Related

Programming :: Cut Column An Edit Data?

Mar 26, 2011

Mar 26 12:32:53 name sshd[3261]: 192.168.1.14Mar 27 12:42:53 name sshd[3262]: 192.168.1.14
how to make this data in output as:

"Mar 26 12:32:53","name","sshd","192.168.1.14"
"Mar 27 12:42:53","name","sshd","192.168.1.14"

View 6 Replies View Related

Programming :: Add A Column To A Text File?

Apr 28, 2011

I have a text field that is just list of servers and I need to add the word hostname in front of them... It must be brain fart but I can't think of how to do this. Basically I need this:

server1
server2
server3

To this:

hostname server1
hostname server2
hostname server3

(And I just mean simply the word "hostname")

View 2 Replies View Related

Programming :: Sed To Search And Insert Column?

Feb 24, 2011

I have the following file.

B0 49.2230869 -102.5743868
C 1LPRK 654.90
C 1PREU 3693.90
C 1JRSU 3693.90

[code]....

I need to insert text ABCDEF starting at position 26 if a line starts with C. I need it to look like:

C 1VKNG ABCDEF 3097.00
C 1JLFU ABCDEF 3157.20
C 1MNVL ABCDEF 3346.10

I would prefer to use sed to do this and not perl.

View 14 Replies View Related

Programming :: Transposing Only Part Of Row Into Column?

Jul 8, 2011

I am trying to transpose the following row:

x1 x2 x3 x4

into

x1 X2
x3 x4

With tr '''' < file I can select all columns to become separate rows,but as you see x3 and x4 have to be grouped when transposing.Or should I use awk for this one?

View 1 Replies View Related

General :: Calculate 3rd Column Which Should Be Addition Of Value In 1 And 2nd Column?

Jul 19, 2010

How would i calculate following values.Initial file

10 3
20 4
How would i calculate 3rd column which should be addition of value in 1 and 2nd column.File after calculation
10 3 13
20 4 24

View 14 Replies View Related

Programming :: Check For Word Frequency In 1 Column

Jul 6, 2010

I have a large tab delimited text file, about 17gb. It only has 6 column. On column number 4, it is all numbers. Ranging from 1-1000. I want to count how many times each number occured. So the output I want is in 2 columns, first one is a number, second column is how many times it occured. I tried

head -n 1000 coverage | cut -f 4 | uniq -c

Didn't work for me, the first column returned is not unique.

View 3 Replies View Related

Programming :: Calculate Data And Make It Into New Column Using Awk?

May 24, 2011

i've been using a awk script to calculate my data... i have 3 files:

file a1.txt:

2
3
4

[code]....

the results were (3.5, 6 and 3) which is pretty easy.. now i want to combine all this into 1 file and each have different columns and called it avg.txt which have something like this in the end:

3.5 6 3

View 1 Replies View Related

Programming :: C - Adding Up Array Column Total?

Jan 25, 2010

I'm having problems adding up column totals using arrays. I've got it to add up the row totals and display at the end of the row. Here is my code so far

Code:

#include <stdio.h>
#include <string.h>
const int maxrows=10;

[code]...

What i need it to do is, add up the columns and display it at the bottom of each column similar to how the row totals display

View 2 Replies View Related

Programming :: Find The Average Of First 12 Numbers In The Third Column Using 'awk'

Nov 20, 2010

I have a text file with 4 columns and 18 rows. All are integers. I wish to find the average of first 12 numbers in the third column using 'awk'.

View 8 Replies View Related

Programming :: Remove Duplicate Entries From First Column?

May 12, 2010

I have a huge (over 10 gb) file with a list of IP's each followed by a corresponding number like this:

Code:

12.32.34.23 10
143.32.34.543 11
232.32.45.65 12
54.23.5.232 13
143.32.34.43 14
and so on..

I'm trying to sort this file numerically and weed out any duplicate IP addresses. How do I do this on bash? I have come up with this but obviously it does'nt work.

Code:

$sort -n myfile.txt | cut -f1 | uniq -u

View 2 Replies View Related

Programming :: Script To Change Column Data?

May 14, 2010

i have a compiled data as follows:

c1
0
0
0

[Code]......

View 13 Replies View Related

Programming :: Search A String And Print Column?

Mar 13, 2010

I need to search a string which is in the first line and print that column.

For e.g

Code:
$ top -bn1 | head -20 | awk '/PID/,/*/'
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 13737 admin 15 0 2476 936 680 R 2 0.0 0:00.01

[Code]....

View 6 Replies View Related

Programming :: PHP - Sorting Multi Dimensional Arrays By One Column

Mar 17, 2009

I just started programming in PHP so I haven't figured out how to do this yet, but I have a multi-dimensional array that I need to sort by one column. That's fine...but I need the sort to ignore case! Right now I have it sorted by 'name' (the other column is 'uid').

The problem is that by the default the sort is case-sensitive so the array looks like this:
Code:
Apple 4015
Banana 4011
Cherry 4045
avocado 4046

I want to be able to sort the the 'name' column in a case-insensitive manner so that the array actually looks like:
Code:
Apple 4015
avocado 4046
Banana 4011
Cherry 4045

How to accomplish this? Just FYI I'm not actually sorting the PLUs for fruits...but it was a simple example. I'm actually doing this for a Facebook application.

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved