Programming :: Count Specific Entries Inside A Block?

Jul 15, 2011

What I want to do is from a file having block like

<event>
8 3 0.2685416E-02
2 -1 0
21 -1 0

[code]...

The first line after the "<event>" is its process-id, so I would like to have at the end a summary of how many "event" block I have for each type, ie how many

6 1 0.2685416E-02

or how many

7 2 0.2685416E-02

etc etc

I do not know in advance how many different-kind of block I will have, so it has to be a bit smart to scan the file, and make an new "summary" info for each unique type I was using something like

awk '/<event>/,/</event>/{if ($3 -eq 0.2685416E-02 ) { print $1" "$2" "$3}}' file > out

and then

grep -c "$1" "$2" "$3" but with no success since my awk commands prints all lines of each block

Suppose, that in advance I do know the $3, ie the 0.2685416E-02 which is a kind of weight

View 8 Replies


ADVERTISEMENT

Programming :: Bash Script To Count Number Of Lines With A Specific Property7?

Aug 11, 2010

I would like to parse an input file in which there are two columns per each row. We want to see how many lines are duplicated where we define duplicate to be having the same second field and different first field. For instance if the input file looks like the following:

79874 13131
79873 12309
79820 13131

[code]...

View 10 Replies View Related

Programming :: Use AWK To Search For A Specific String Inside Html?

Jan 26, 2010

how to search for a specific string of text inside an html document. I then want to cut out that specific data that the field or string contains. I want to do a shellscript that makes this function automaticly.

For example:

#
#Here i want to find the field "town" inside the html/java and then cut #out the town name from it and paste that to an file.
#
#

[Code].....

View 8 Replies View Related

Programming :: DBD::mysql::st Execute Failed: Column Count Doesn't Match Value Count At Row 1

Feb 24, 2010

I have the following perl/DBI script:

Quote:

#!/usr/bin/perl
use DBI;
my ($db, $user, $pw) = ('dbname', '****', '***********');
my $dbh = DBI->connect("DBI:mysql:$db",$user,$pw) or die "Cannot connect to $db: $DBI::errstr

[code].....

The error message is

[Wed Feb 24 13:03:27 2010] myscript.cgi: DBD::mysql::st execute failed: Column count doesn't match value count at row 1 at myscript.cgi. [Wed Feb 24 13:03:27 2010] myscript.cgi: DBI::db=HASH(0x8a30c60)->errstr

View 2 Replies View Related

Server :: Sendmail: Block Specific Sender To Specific Recipient?

Oct 1, 2009

I'm trying to configure our mail server to block email from a specific sender reaching a specific recipient. In other words, if one of our employees is getting harassed by a 'stalker', how would one go about blocking, at the MTA (Sendmail) level, a specific sender email address from reaching a particular users inbox? We do not want to capture the email - simply block it before it consumes server resources.The Sendmail server (MTA) is a front end to our Exchange server so no user accounts exist on the Linux server. We simply use it as a SPAM and Virus scanner then forward clean email to the Exchange server.

View 6 Replies View Related

General :: Count The Number Of Lines Inside A File And Put The Output Into A Variable?

Feb 1, 2011

i need to count the number of files and put the output into a variable. i used wc -l filename but i couldnt find an option to put the output to variable. example if the number o line is 5, i need the output of echo $x is 5.

View 3 Replies View Related

Ubuntu :: Ext4 Block - Inode Count Wrong ?

Jun 28, 2010

I'm running a small development server on Ubuntu 10.04 server 64 bit with ext4 as the File system type.

I keep on getting wrong block / inode size when I do an fsck:

Code:

I then force an fsck and the problem is solved, but given a day or two, the problem is back. This can sometime consume up to 10G of my HDD space.

Code:

View 3 Replies View Related

General :: Showing The Line Count Of A Specific File

Mar 30, 2011

Is this the correct way to show the line count of a specific file?

cat file | grep * -c

View 3 Replies View Related

General :: Cannot Mount Hard Disk: Block Count Exceeds Size Of Device

May 11, 2011

I have one hard disk (call her HDA) that contains nothing but a single ext4 partition containing a backup of all my important data. Last night I did a clean install of Ubuntu 10.10 on my primary hard disk (call her HDB) and from there proceeded to upgrade directly to Ubuntu 11.04 upgrade. In 10.10, I was able to read HDA just fine. However after the upgrade, I can no longer mount this drive. When mounting from file browser:

Code:

Error mounting: mount: wrong fs type, bad option, bad superblock on /dev/sda,missing codepage or helper program, or other error In some cases useful info is found in syslog - try dmesg | tail or so The end of dmesg said the following:

Code:

dmesg | tail
[ 82.130904] EXT4-fs (sda): bad geometry: block count 122096646 exceeds size of device (122096381 blocks)

my hard disk has a block count greater than the size of my device. I've done my background searching on this and tried a command line utility I've never heard of before:

Code:

# sudo e2fsck /dev/sda
e2fsck 1.41.14 (22-Dec-2010)
The filesystem size (according to the superblock) is 122096646 blocks
The physical size of the device is 122096381 blocks

[code]....

this is as far as I've gotten. This drive holds over a decade's worth of work for me and is extremely valuable. I really didn't think that the Ubuntu upgrade process would mess with this drive, seeing as the Ubuntu install was contained on an entirely different drive. What is it that I need to do to restore my drive to working status?

View 9 Replies View Related

Hardware :: External Hard Drive / Cannot Format / Warning: Block Count Mismatch: Found 78xxxxx But Assuming 0'?

Oct 21, 2010

I have WD external hdd (80GB) formatted with fat32. I was using this hdd to transfer the data from computer A (LINUX, RH9) to computer B (Win7).

I was keep copying and deleting the data in the WD hdd during the data transfer because the amount to transfer is more than 300GB.

After doing this several times (and the WD drive was emptied), comp. A said the disk is full. I checked using 'df' and it was really full but 'ls -la' shows that there is no data in it.

I checked it in comp. B, and it showed empty. I tried to format in comp. A using 'mkdosfs -F 32 /dev/xxx# (block#)', but showed an error message like below.

'Warning: block count mismatch: found 78xxxxx but assuming 0'.

I found a similar situation in this forum metioning 'possible damaged linux kernel (not exactly same expression though)', so I re-installed linux in comp. A, but the problem was not solved.

1. why the disk info. is showed differently in linux and win7
2. why I cannot format it

View 3 Replies View Related

Server :: Sendmail - Block Email To Root From Outside But Keep Receiving From Inside

May 5, 2010

I have a small internal network with about 8 or so servers or workstations. My mail server is getting spammed from all over to the root and other administrative accounts. I also get valid email sent to the root and administrative accounts from within my local network. Is there a way to block all email coming from outside my local network while still receiving it inside the local network to these specific accounts?

View 2 Replies View Related

General :: How To Find A File With Specific String Inside It

May 7, 2010

Is there any way i can find a file with specific word inside it.For example if i want to find a file which has some text written inside it.How would i form a command to search them?

View 5 Replies View Related

Server :: LVM - Mount Specific Partition Inside Logical Volume?

Sep 4, 2009

I've just started playing with virtualization and I started my first VM. I would like to know if it's possible for the host machine to mount the partitions of the VM when it's closed. Right now the VM uses /dev/vg0/vm1 and has 3 partitions on it. I tried mount /dev/vg0/vm1 ~/vm1 at first before I remembered that I'd need a way to mount a specific partition inside the logical volume, not the volume itself!

View 2 Replies View Related

Ubuntu :: Stop Update-grub2 Automatically Adding Entries For Specific Partitions?

Aug 20, 2010

I like to load other distro's via their own grub.

So at the min I add an entry to code...

however when update-grub2 is run it also adds its own entries (for arch linux).

Is there a way to stop the update-grub2 script automatically adding a entry on a specific partition ?

View 3 Replies View Related

General :: Booting - Error "Extended Attribute Block 18875430 Has Reference Count 2 - Should Be 1"

Jan 1, 2011

While booting my Linux System (Red hat Enterprises edition 5.1) I am getting a messsage as below , the message is getting generated during file checking on first boot. Extended attribute block 18875430 has reference count 2 , should be 1. and after this system remains in the same sate.

View 1 Replies View Related

Ubuntu :: Block IPs When Hitting Specific URL?

Feb 11, 2011

I've noticed in my Apache logs a lot of hits to a specific URL on my server. The thing is, the URL is invalid and returns a 404. Every hit has a different Agent ID (things like Windows NT 4 and IE 8, Mac OS and Safari, Windows 7 and Mozilla, etc) and usually a slightly different IP address. If you browse the URL with Chrome/Firefox, it gets reported as potential phishing activity - despite it only returning a 404 error.

I blocked a range of IPs with IPTables which worked for a while, but I can see the IP address has changed again (outside of the range I set) and is generating logs again.

Is it possible to automatically block any IP attempting to access this specific URL?

View 1 Replies View Related

General :: Block A Specific MAC Address?

Feb 5, 2011

how to block a specific MAC address

View 2 Replies View Related

General :: Any Way To Block Specific Websites?

Jul 28, 2011

How to block unwanted sites.

View 1 Replies View Related

General :: Block A Specific Content Using Squid?

Aug 24, 2010

In Iran there is a famous "access denied page" that redirects you to a strange page with a lot of HTML errors and lol, telling you RTFM about ridiculous Internet laws.I want to filter the contents of the page, because the page IP, URL, ... are all unknown.I don't know much about squid configuration scripts.I can read but cannot write

View 1 Replies View Related

Networking :: Generic Way To Block Specific Port?

Jul 9, 2011

Recently I discovered that we were accidentally running a POP server (port 110), when we only should have been running the encrypted version thereof (port 995). This wouldn't have been a problem if the port was blocked in the first place. I had wrongly assumed that any port NOT specifically listed in one's firewall rules (CentOS 5 with default iptables installation) would be blocked. I thought you had to add a rule to /etc/sysconfig/iptables in order to open up a port. Apparently this is NOT the case. So is it true that if I install some random software that starts listening on any number of ports that I have not specifically mentioned in /etc/sysconfig/iptables that it will not be blocked - it will work right away?

Anyway, I guess two questions:
1) What's a generic way to block a specific port? I use rules like this to "open" ports (although is this not needed if they're open anyway?)
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT
What's the analog of this kind of rule to *block* a port?
2) Is there a better way to configure iptables to block all ports that are not mentioned in its configuration? Is that dangerous? (will it block things that I don't want to block?)

View 3 Replies View Related

Programming :: Search A Bunch Of Files In A Specific Folder For A Specific Number?

Jul 24, 2010

I need to search a bunch of files in a specific folder for a specific number and add all the numbers together to a total sum. I use Rsync everyday, everytime I run rsync i get a logfile (rsync output) witch contains the textstring "Total bytes sent: xxxxxx".

The "xxxxx" can vary in lenght. I need to extract the "xxxxxx" from each file and add the numbers together to a total size over a week or a month. Is this possible? And I wish to only use bash. One way of doing stuff at a time my friends .

View 5 Replies View Related

OpenSUSE :: Can Apparmor Block Execute Any Program In A Specific Dir

Jun 10, 2010

prohibit execution of any program include shell command, only be profiled program could be executed, can apparmor do that?

View 5 Replies View Related

General :: Block A Specific User To Run SSH And Leave Him The Access To FTP?

Jun 19, 2010

I run the openssh daemon on port 22 and have the proftp running on port 21. I would like to block SSH for a specific user.I use proftpd.I would like to prevent the SSH access for this user and leave the FTP working for this user specific.Into /etc/passwd, I tried to change the /bin/bash to /bin/false, but this blocks both SSH and FTP access for this account.

View 3 Replies View Related

Networking :: Block Specific Websites - Preferred Method ?

May 19, 2010

I'm trying to block specific websites, preferably using a portion of the url.

For example, if blocking [url], [url] would also be blocked. This implies that simply blocking a single IP using iptables would not work well.

The names to block will be somewhat dynamic, so a list specification would be ideal.

In my case, the LAN has a mix of linux and ms machines, and they all use a linux gateway currently running dnsmasq.

I find suggestions from using /etc/hosts (might work with yp, but not ideal) on the gateway machine, through to using squid on the gateway machine.

View 9 Replies View Related

Security :: Block Computer From Connecting To A Specific IP Address?

Feb 13, 2010

I was taking a peek at the active connections shown by the Firestarter GUI and noticed the following (the source is my computer):

SourceDestinationPortServiceProgram
192.168.0.11266.235.133.4280HTTP

I closed all Internet related apps and the connection persisted. After a reboot it did not reconnect (yet).The IP address appears to belong to esomniture.com - some sort of web analytics company. How do I prevent my computer from connecting to these rascals. I have found a lot of documentation regarding stopping inbound connections to services on my computer but not the other way. I have various filtering addons installed in Firefox however, this connection seems to be at a lower level as no program is specified as being responsible for the connection.

View 8 Replies View Related

Programming :: Replace Specific Character After Specific Line By Awk?

Jul 19, 2010

I want to replace specific character in a file after every specific line. example as follows.

O 000000000000000000
A 111111111111111111
C 222222222222222222

[code]...

View 2 Replies View Related

General :: Display Specific Block Of Contents Or Lines In Output?

Apr 23, 2010

Consider a situation in which you want to display only specific lines of contents from a file or of a command's output. Yes, we have head and tail commands. But, how to view all the lines of a file except the last one or vise versa when we don't know the count of lines in advance?

Consider this output:

Code:

[root@localhost ~]# ps au | grep bash
root 6316 0.0 0.0 4672 1440 tty1 Ss+ Apr22 0:02 -bash
root 20847 0.2 0.0 4672 1432 pts/0 Ss Apr23 0:12 -bash
root 21167 0.0 0.0 3920 660 pts/0 S+ 01:00 0:00 grep bash

Here, I don't want the last line (in italic) to be included in the result since the last line is due to "grep bash" in the devised command "ps au | grep bash". Well, we can rewrite the devised command:

Quote:

"ps au | grep bash | head -n 2"

But, again, here we are specifying the count of lines to be included. But, in the presented problem we don't know any count in advance!

View 6 Replies View Related

Ubuntu :: Laptop Boot Failure - Invalid Enviroment Block - Unable To Load Default Boot Entries

Mar 3, 2010

Have been running ubuntu for sometime now and love its functionality...However since a recent update have the following issues..When I power on the laptop I get the toshiba logo followed by grub loading with the message ' invalid enviroment block" "unable to load default boot entries". When I then try to run the laptop off a LiveCd, the ubuntu splash screen appears with the loading process bar (horizontal line) displayed..however it then appears to display a black screen with no further activity..Now all of this is via an external monitor as my laptop screen shows no activity right from the very start with just a blank screen....so am really stuck here wondering if its a harware/software issue or a combination of both...

View 1 Replies View Related

Programming :: Count The Files For Each Sub Folder?

Jan 11, 2011

I want to count the number of files in each sub folder of a directory structure. At the moment I can do:

ls -1R /Folder | wc -l

Which lists the item count for all the folders as one. I can do:

ls -1R /Folder wc l

Which lists all the folders in the top level and all the items. Is there any way to get the list of folders and then item count for each folder?

View 1 Replies View Related

Programming :: How To Implement Count Word

Nov 9, 2010

I have these but not working.

size_t count_words(const std::string& s)
{
std::istringstream is(s);
return distance( std::istream_iterator<std::string>(is),
std::istream_iterator<std::string>());
}
and
std::string s; // word count
unsigned int wordno = 0;
while(getline(myfile, s))
{ ++wordno;
if(s.empty())++ wordno;
else wordno += count_words(s);
std::cout << s << '
';
}

myoutput1<< "Number of words : " << wordno << '
';
myoutput1 << "
Word" <<" " <<" Occurrence" <<endl;
myoutput2<< "Number of words : " << wordno << '
';
myoutput2 << "
Word" <<" " <<" Occurrence" <<endl;

View 6 Replies View Related







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