Sponsored Content
Top Forums Shell Programming and Scripting grep required data from two columns Post 302287701 by esham on Sunday 15th of February 2009 07:11:41 AM
Old 02-15-2009
Hi,

Suppose you have the data in file:datavol

here is the code

Code:
#! /usr/bin/perl
use warnings;

open (DATAFILE, "+<datavol") or die $!;

my @mydatafile = <DATAFILE>;
my $data = join(" ",@mydatafile);

$data =~ s/(\n)//g;
#$data =~ s/, /,/g;
$data =~ s/(vol[0-9*])/\n$1/g;
my @arraydata = split(/\n/, $data);
foreach $value (@arraydata){
if ($value =~ /disabled/){
        print "\n";
        my @words = split(/\s+/,$value);
        print "$words[0] guarantee=volume(disabled)";
}
}
close DATAFILE;


Code:
[ahamed@localhost general]$ ./datavol.pl 

vol8 guarantee=volume(disabled)
vol9 guarantee=volume(disabled)
vol4 guarantee=volume(disabled)
vol5 guarantee=volume(disabled)
vol6 guarantee=volume(disabled)
vol7 guarantee=volume(disabled)
vol1 guarantee=volume(disabled)
vol2 guarantee=volume(disabled)
vol10 guarantee=volume(disabled)
vol11 guarantee=volume(disabled)
vol12 guarantee=volume(disabled)


Thanks
Ahamed Shameer
netgiz.net -
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help required in grep command

Hi all, I need some help in grep command in a ksh script. Actually, i need to list all files having the file name like "BORD*.DAT" but exclude the files (from the list) having name like "BORD*mgt*.DAT". For that i used the following command: ls | grep "BORD*.DAT" | grep -v "BORD*mgt*.DAT" ... (4 Replies)
Discussion started by: panzer
4 Replies

2. Shell Programming and Scripting

shell script required to convert rows to columns

Hi Friends, I have a log file as below siteid = HYD spc = 100 rset = RS_D_M siteid = DEL spc = 200 rset = RS_K_L siteid = DEL2 spc = 210 rset = RS_D_M Now I need a output like column wise as below. siteid SPC rset HYD 100 RS_D_M (2 Replies)
Discussion started by: suresh3566
2 Replies

3. UNIX for Advanced & Expert Users

sort out the required data

Hi All, I have a file 1.txt which has the duplicate dns entries as shown: Name: 000f9fbc6738.net.in|Addresses: 10.241.66.169, 10.84.2.222,212.241.66.170 Name: 001371e8ed3e.net.in|Addresses: 10.241.65.153, 10.84.1.101 Name: 00e06f5bd42a.net.in|Addresses: 10.72.19.218,... (6 Replies)
Discussion started by: imas
6 Replies

4. UNIX for Dummies Questions & Answers

Suggestion to convert data in rows to data in columns

Hello everyone! I have a huge dataset looking like this: nameX nameX 0 1 2 2 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ............... nameY nameY 2 2 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ..... nameB nameB 0 1 2 2 2 2 2 2 2 2 1 2 2 2 1 2 2 2 ..... (can be several thousands of codes) and I need... (8 Replies)
Discussion started by: kush
8 Replies

5. Shell Programming and Scripting

Checking required columns in the file

Hi, File contains with TAB delimeter file,i want check the 2,3 are not null test1@gmail.com 100 test test2@gmail.com 101 test test3@gmail.com test test4@gmail.com 102 OUTPUT test1@gmail.com 100 test test2@gmail.com 101 test Please help me with one single command in... (2 Replies)
Discussion started by: muralikri
2 Replies

6. Shell Programming and Scripting

Checking the required columns in File

Hello Experts, File contains 10 columns with | delimeter. 1,3,4,5,7,9 columns are required columns means it should contains values. i need those records, rest of it will contain or not contain data. test1.txt: a@a.com|a|b|c|d|e|f|g|h|i |a|b|c|d|e|f|g|h|i b@b.com|a||c|d|e|f|g|h|i... (7 Replies)
Discussion started by: muralikri
7 Replies

7. Shell Programming and Scripting

Required help to print diff columns for 2 patterns using awk

Hi All, I need help for below scenario : I have a principals.xml_24092012backup file : cat principals.xml_24092012backup </user> <user username="eramire" password="2D393C01720749256303D204826A374D9AE9ABABBF8A"> <roleMapping rolename="VIEW_EVERYTHING"/> </user> ... (2 Replies)
Discussion started by: kiran_j
2 Replies

8. Shell Programming and Scripting

Help Need to fetch the required data

Hi Guys, Am in need of your help one more time on my real data. I have a file which contains more than thousand lines of data Live data shown for 4 iterations. We have more than thousand lines of data:- -------------------------------------------------------------------------- ... (4 Replies)
Discussion started by: rocky2013
4 Replies

9. UNIX for Beginners Questions & Answers

UNIX shell script required to read two columns from xml

Hello All, I am new to unix scripting. I need to read FROMINSTANCE, FROMFIELD from below XML code and need to write a script for insert into SQ_EPIC values( "DID", "PROJECT_NAME") Select DID, PROJECT_NAME from EPIC<CONNECTOR TOINSTANCETYPE="Source Qualifier" TOINSTANCE="SQ_EPIC" TOFIELD="DID"... (7 Replies)
Discussion started by: sekhar.lsb
7 Replies

10. UNIX for Beginners Questions & Answers

How to print multiple required columns dynamically in a file using the header name?

Hi All, i am trying to print required multiple columns dynamically from a fie. But i am able to print only one column at a time. i am new to shell script, please help me on this issue. i am using below script awk -v COLT=$1 ' NR==1 { for (i=1; i<=NF; i++) { ... (2 Replies)
Discussion started by: balu1234
2 Replies
load_datafile_callback(3alleg4) 				  Allegro manual				   load_datafile_callback(3alleg4)

NAME
load_datafile_callback - Loads a datafile into memory, calling a hook per object. Allegro game programming library. SYNOPSIS
#include <allegro.h> DATAFILE *load_datafile_callback(const char *filename, void (*callback)(DATAFILE *d)); DESCRIPTION
Loads a datafile into memory, calling the specified hook function once for each object in the file, passing it a pointer to the object just read. You can use this to implement very simple loading screens where every time the hook is called, the screen is updated to let the user know your program is still loading from disk: void load_callback(DATAFILE *dat_obj) { static const char indicator[] = "-\|/-.oOXOo."; static int current = 0; /* Show a different character every time. */ textprintf_ex(screen, font, 0, 0, makecol(0, 0, 0), makecol(255, 255, 255), "%c Loading %c", indicator[current], indicator[current]); /* Increase index and check if we need to reset it. */ current++; if (!indicator[current]) current = 0; } ... dat = load_datafile_callback("data.dat", load_callback); RETURN VALUE
Returns a pointer to the DATAFILE or NULL on error. Remember to free this DATAFILE later to avoid memory leaks. SEE ALSO
load_datafile(3alleg4), unload_datafile(3alleg4), load_datafile_object(3alleg4), set_color_conversion(3alleg4), fixup_datafile(3alleg4), packfile_password(3alleg4), find_datafile_object(3alleg4), register_datafile_object(3alleg4) Allegro version 4.4.2 load_datafile_callback(3alleg4)
All times are GMT -4. The time now is 03:17 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy