-
January 14th, 2008, 09:31 PM
#1
unix help
1.
i am trying to build a command that searches a text file
and outputs the number of words which consists of two 'b' characters
in each word separatly
like
barby
(the b characters must be separated from one another)
i tried to use grep [b][b] filepath
then i know that we need to use pipe to count the result
but it prints all the word with the two b chars
one next to the other
how do i build this command
2.
i am trying to build a command that searches a text file
and outputs the number words which consists of two 'x' characters
only
i tried to use
-
January 14th, 2008, 10:39 PM
#2
Oliver's Law:
Experience is something you don't get until just after you need it.
-
January 14th, 2008, 10:57 PM
#3
i tried it the probles that
now i can count them but i cant figure out
how to filter out the undesirable words
-
January 15th, 2008, 07:24 PM
#4
I don't know of a command, but you can do this with a perl script.
*dusting off perl skills*
...
*dusting failed. using can of compressed air*
Code:
#!/usr/bin/perl
$file = "testing.txt";
open (CRAP,$file) || die "Can't open file '$file'. Reason: $!\n";
@garbage = <CRAP>;
close CRAP;
foreach $i (@garbage){
@words = split(/ /,$i);
foreach $w (@words){
chomp($w);
# Uncomment one of the lines below for desired effect,
# but make sure to comment out the one you don't want:
# v Matches only letters between 2 b's. Uncommented as default.
if ($w =~ /b[a-zA-Z]+b/i){
# v Matches any alphanumeric characters between 2 b's
# (including numbers and _) ie, b1g_a55_b00ty
# if ($w =~ /b\w+b/i){
$count++;
push (@results, $w);
}
}
}
if ($count<1){
print "No results found.\n";
}else{
print "Found $count matches. Writing results to file 'results.txt' in this directory. \n";
# This will overwrite results.txt if it already
# exists. To simply append new results to the
# existing file, change >results.txt to >>results.txt
open (RES, ">results.txt") || die "Cannot open results.txt for writing. Reason: $!\n";
foreach (@results){
print RES $_;
print RES "\n";
}
close RES;
}
Tested with a NYTimes article about baseball so I was able to debug a bit so the results file looks nice and clean.
So, what did I do all this for? Why do you need to find 2 b's spaced apart? Just curious...
Also, this will work for x's as well. Just change /b[a-zA-Z]+b/i to /x[a-zA-Z]+x/i
If they need to be together and not seperate the you need to take out everything between the letters, ie: /xx/i
The i means case-insensitve, so if you only want to look for XX or xx or Xx and not xX then take the i off.
-
January 16th, 2008, 06:24 PM
#5
-
January 16th, 2008, 08:22 PM
#6
Oh, well excUUUUUUUUUUUse me sir,
if ur running unix you can edit the script with filenames and run it at the command line. or you can rewrite it to accept filenames as args and use it as a command, not that hard. or you can just keep checking back and seeing if anyone has posted ur golden command.
fuggin' beggers trying to be chosers...
-
January 16th, 2008, 09:29 PM
#7
Originally Posted by xiphias360
Oh, well excUUUUUUUUUUUse me sir,
fuggin' beggers trying to be chosers...
Where the hell did I put the Neg-0-Matic 2000?
Nice script x, I do have one question however, why did you write it? Really?
09:F9:11:02:9D:74:E3:5B 8:41:56:C5:63:56:88:C0
-
January 16th, 2008, 09:36 PM
#8
@ xiphias360:
1. Go to your hardware store and buy a sledge hammer
2. Preferably, but you need to be older than you sound: get a 9mm automatic weapon.
3. Issue the command: "run this you feckin booger or die" Remember to raise the hammer/point the weapon before entering the command.
Points to remember........... no matter what sort of OS or hardware you run,
They DO NOT understand:
1. Semtex
2. C4/PE4
3. Thermite
4. Industrial strength corrosives
So command lines including those statements won't work
-
January 16th, 2008, 10:07 PM
#9
cuz i knew it could be done quick & easy with perl, and to help this ungrateful tard. well no more mr. nice X...
and what's a Neg-o-matic supposed to be? neg rep??
OMG! It's neg rep! everybody RUUUUUUUUUUN!!!!!!!!!!!!!
board points don't pay my car note, so im probably not gonna cry if i loose them, lol...
-
January 17th, 2008, 12:53 PM
#10
I don't think that you were the target dinowuff had in mind?
Similar Threads
-
By gore in forum Operating Systems
Replies: 31
Last Post: June 5th, 2006, 03:50 PM
-
By \/IP3R in forum AntiOnline's General Chit Chat
Replies: 16
Last Post: March 7th, 2005, 10:25 PM
-
By gore in forum Operating Systems
Replies: 1
Last Post: October 12th, 2004, 07:29 AM
-
By -DaRK-RaiDeR- in forum Newbie Security Questions
Replies: 9
Last Post: December 14th, 2002, 08:38 PM
-
By Remote_Access_ in forum Security Archives
Replies: 10
Last Post: January 12th, 2002, 05:02 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|