Sponsored Content
Top Forums Shell Programming and Scripting How to get count of replacements done by sed? Post 302651185 by balajesuri on Tuesday 5th of June 2012 06:24:05 AM
Old 06-05-2012
Code:
[root@host dir]# cat input
ramdom text
random text
HttpDefaultsGui hello world mars enabled="true"
name="HTTPSampler.proxyHost">hello<
name="HTTPSampler.proxyHost">mars<
nama="HTTPsSampler.proxyHost">.*<
</ConfigTestElement
ramdom text
ramdom text
[root@host dir]#
[root@host dir]# cat test.pl
#! /usr/bin/perl -w
use strict;

my $gProxyHost = "helloworld";
my $cnt = 0;

open FILE, "< input";
for (<FILE>) {
    if (/HttpDefaultsGui.*?enabled="true"/ .. /<\/ConfigTestElement/) {
        (/HttpDefaultsGui.*?enabled="true"/ || /<\/ConfigTestElement/) && next;
        $cnt += s/name="HTTPSampler.proxyHost">.*?</name="HTTPSampler.proxyHost">${gProxyHost}</;
        print;
    }
}
close FILE;

print "$cnt\n";
[root@host dir]#
[root@host dir]# ./test.pl
2

 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Record count problem using sed command

Hi, I have a script which removes 2 header records and 1 trailer record in a list of files. The commands doing the actions are sed '1,2d' $file > tempfile1.dat sed '$d' < tempfile1.dat > $output.txt Its working fine for all records except a file having size=1445509814 and number of... (2 Replies)
Discussion started by: ayanbiswas
2 Replies

2. Shell Programming and Scripting

Conditional replacements

Hi, I have a requirement as below Input Jacuzzi,"Jet Rings, Pillows",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,, Jacuzzi,"Jet Rings, Pillows, Skirt/Apron",Accessory,Optional,,9230917,69094,,P556805,69094,FALSE,1,0,, Output Jacuzzi,"Jet Rings!@%... (6 Replies)
Discussion started by: kewk
6 Replies

3. Shell Programming and Scripting

Gen random char then sed replacements

Hey guys, I need to first generate some random characters, which I am already doing perfectly as follows: randomize=`cat /dev/urandom | tr -dc "a-z0-9" | fold -w 6 | head -n 1` This is where I am stuck...I need to sed replace some static values with those random characters, but I need each... (4 Replies)
Discussion started by: holyearth
4 Replies

4. UNIX for Dummies Questions & Answers

How to use sed to do multiple replacements all at once?

I have a text file where I want to use sed to do multiple replacements all at once (i.e. with a single command) . I want to convert all AA's to 0, all AG's to 1 and all GG's to 2. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

5. UNIX for Dummies Questions & Answers

Selective Replacements: Using sed or awk to replace letters with numbers in a very specific way

Hello all. I am a beginner UNIX user who is using UNIX to work on a bioinformatics project for my university. I have a bit of a complicated issue in trying to use sed (or awk) to "find and replace" bases (letters) in a genetics data spreadsheet (converted to a text file, can be either... (3 Replies)
Discussion started by: Mince
3 Replies

6. Shell Programming and Scripting

awk delete newline after other replacements

Dear All, could you please help me to remove \n characters after all other replacements have been done as in the code below: { #remove punctuation and starting whitespaces gsub("]"," "); $1=$1; } { #print lines containing 'whatever' if ($1=="whatever") {print} #print... (3 Replies)
Discussion started by: shivacoder
3 Replies

7. Shell Programming and Scripting

BASH script to read external file to perform text replacements?

Hi all, I have a moderate size (300 lines) BASH Shell script that performs various tasks on different source reports (CSV files). One of the tasks that it performs, is to use SED to replace 'non-conforming' titles with conformant ones. For example "How to format a RAW Report" needs to become... (3 Replies)
Discussion started by: richardsantink
3 Replies

8. Shell Programming and Scripting

Optimizing find with many replacements

Hello, I'm looking for advice on how to optimize this bash script, currently i use the shotgun approach to avoid file io/buffering problems of forks trying to write simultaneously to the same file. i'd like to keep this as a fairly portable bash script rather than writing a C routine. in a... (8 Replies)
Discussion started by: f77hack
8 Replies

9. Shell Programming and Scripting

Using = with sed to increase sequence count

I have a fasta file like this one: >ID1 AAAAAA >ID2 TTTTTT And I am using this sed script to increase the count sequence sed '/^>/s/.*//;/^$/=;/^$/d' text.txt | sed 's/.*/echo ">seq" \$(( ( & + 1 )\/2 ))/e' I get the desired output: >seq 1 AAAAAA >seq 2 TTTTTT However, this... (9 Replies)
Discussion started by: Xterra
9 Replies

10. Shell Programming and Scripting

Help building a variable string from a keyword - character replacements!

Hello scripting geniusii! I come to kneel before the alter of your wisdom! I am looking to take a keyword and replace characters within that keyword and add them to a string variable. I would like this to only go through however many characters the word has, which may vary in size. ... (10 Replies)
Discussion started by: ghaniba
10 Replies
SPIKEPROXY(1)						      General Commands Manual						     SPIKEPROXY(1)

NAME
spikeproxy - web application auditing tool SYNOPSIS
spkproxy [-s SSLproxyhost] [-p port] [-U NTLMUser] [-D NTLMDomain] [-P NTLMPassword] [-l ListenHost] [-c cache_directory] DESCRIPTION
This manual page documents briefly the spikeproxy command. This manual page was written for the Debian distribution because the original program does not have a manual page. SPIKE proXY functions as an HTTP and HTTPS proxy, and allows web developers or web application auditors low level access to the entire web application interface, while also providing a number of automated tools and techniques for discovering common problems. These automated tools include: 1.Automated SQL Injection Detection 2.Web Site Crawling (guaranteed not to crawl sites other than the one being tested) 3.Login form brute forcing 4.Automated overflow detection 5.Automated directory traversal detection In addition to automated analysis, SPIKE proXy allows the user to penetrate into the internals of the web application by viewing and chang- ing all variables, cookies, headers, or other parts of the request and resubmit them. SPIKE proXy maintains a careful record of each request made - saving both each request, and the entire response. The user can later go back and replace any request or view any response. OPTIONS
This program can be configured with the options listed below. The options may be given in any order. -c cache directory The directory that will be used to cache all the requests. This directory is created if it does not exist. The default location is /var/cache/spikeproxy but it can only be used by the root user. -l listenhost The IP address the proxy will listen on (it defaults to 127.0.0.1 so it is not available from external hosts). -p port This option sets the port the proxy will listen on (it defaults to 8080 if not provided). -h proxyHost Sets a proxy host to use in the proxy chain. Spike will forward all requests to this proxy. -H proxyPort Sets the port for the proxy host. -s proxySSLHost Sets a proxy host for SSL connections. Spike will forward all SSL requests to this proxy. -S proxySSLPort Sets the port for the SSL proxy host. -U NTLM Username Defines the NTLM username it will use when authenticating to the proxy host. -P NTLM Password Sets the password it will use when authenticating to the proxy host. -D NTLM Domain Sets the NTLM domain it will use when providing credentials to the proxy host. SEE ALSO
The program provides inline documentation in the user interface when connected to it through a web client. If you are trying to audit a web application you might want to read OWASP Guide to Building Secure Web Applications and Web Services, Application Security Attack Components project, Application Security Testing Framework, and the OWASP Web Application Security TopTen available at http://www.owasp.org and the World Wide Web Security FAQ available at http://www.w3.org/Security/Faq/ AUTHOR
This manual page was written by Javier Fernandez-Sanguino Pen~a <jfs@computer.org>, for the Debian GNU/Linux system (but may be used by others). October 2, 2006 SPIKEPROXY(1)
All times are GMT -4. The time now is 02:54 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy