Programming :: Extract Value From String?

Dec 27, 2008

I need to extract a price from a string, this may vary in the future so it may be 12.99 or 14.99. i thought a sed command might crack it and i need to write to a file:<td><b class="priceLarge">?6.99</b>I need to extract the price 6.99(with no ?)so extract anyhting between "> and </B> and write it to a file such as tmp1.txt .

View 1 Replies


ADVERTISEMENT

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

General :: Extract A String Within A String Using A Pattern?

Nov 4, 2010

i have a file name using the following pattern:

PREFIX: AR
SOURCE: LEGACY
DATETIME: YYYYMMDD_HH24MISS
SUFFIX: .txt

sample filename:AR_LEGACY_20101104_105500.txti want to extract the source which is LEGACY in this case. how do i do this using shell?

View 1 Replies View Related

Programming :: Copy String A To String B And Change String B With Toupper() And Count The Chars?

Oct 22, 2010

copy string a to string b and change string b with toupper() and count the chars

View 3 Replies View Related

General :: Extract The First Word Following A String?

Aug 22, 2010

I need a bash script that can read a file, say example.txt search for the string "This is my example string" and save whatever word/number comes immediately after it to a variable, var.

Example:
blah blah
blah This is my example string extracthere is a very nice word.
blah blah

There are two constraints:1. This needs to assume as little as possible about the nature of the known string "This is my example string" and the word that follows it. I am trying to keep my code adaptable.2. Speed is valuable. This shell will be executed dozens if not hundreds of times so speed is very desirable. I thought I read that some commands are faster than others.

View 14 Replies View Related

Software :: Extract Lines Between Two Patterns Containing Certain String?

Jun 16, 2010

I have a file that I need to scan and output data between Number and End containing string 123.
Number 1:
6
7
123
1
End

View 1 Replies View Related

Programming :: Pthread - Take String From The Command Line And Creates A Thread To Print The String

May 3, 2011

I've been trying to understand pthread in C a little better. So I made a simple program that takes in a string from the command line and creates a thread to print the string. I've looked online and copied the basic concepts but there are something things I'm confused about. The programs works just fine, but I have questions. Here's what I have so far.

[Code]....

One thing I'd like to know is why the 3rd argument in the pthread_create function which is my SendMessage function needs to be typecasted to a void pointer and then send the address of the function. Also as for the 4th argument, I would see typecasting to void pointer in some of the pthread examples I saw online, but in my case I'm passing a char pointer, would this be correct? In which case would I ever want to pass a void pointer?

Do I need a pthread_exit(NULL) in my main and in the SendMessage function? If so, why? I added the sleep() function so that I could let the pthread_exit function in my SendMessage function execute first. I simply saw that the online examples on pthread had pthread_exit() in both locations.

View 6 Replies View Related

Programming :: Using Sed Replace Line Containing Particular String By A Single String?

Oct 16, 2010

I have a set of lines as ahown below:

Leon went to school
Leon came back from school..
Leon had dinner...

I have to replace the line containing "dinner" by a single string LUNCH...

View 2 Replies View Related

Programming :: Creates String Suffixes Out Of A Reference String?

Feb 25, 2011

I need to creates string suffixes out of a Reference string. for eg. suffixes of abcdefg will be

1)bcdefg
2)cdefg
3)defg
and so on...

create an array of pointers to point to the first few characters and then use that pointer to print the rest of the string.But when i print using the pointer i get GARBAGE values! shudn't std::cout<<ptr[w] print the string following the char it is pointing to? why do i get garbage values?

View 9 Replies View Related

Programming :: C - Put A Specific Arbitrary Part Of A String Into It's Own String?

Apr 18, 2010

So if I'm given a location of a file like:

How can I just take the type of the file at the end? I know I can use strrchr() for a period to get the pointer to the period just before file type. Is there a build in string function that will just take the rest of the string from a certain point on forward in the string? I know it wouldn't be much work to make it myself, but I figured I would find out if it already existed before doing it.

View 9 Replies View Related

Programming :: Convert String To Integer Back To String C++ ?

Mar 13, 2010

Code:

The error is:

Code:

What I want to do is take input of ip4 as a string, convert it to an integer to add 1 to it, then reconvert it back to a string. Its not working.

My full code is:

Code:

View 1 Replies View Related

Programming :: Assigning Custom String To Std::string In C++?

Oct 12, 2009

I've been given a custom-made string class which handles string, wstring and bstr. It has a number of methods and assignment operators to convert to and from different types. The app I work on compiles happily in VS6 and VS2008, but when trying to compile in Redhat (version 4.1.1 in Redhat 5.0)

[code]....

View 4 Replies View Related

Programming :: How To Check If All Letters Of One String Are In Another String?

Nov 11, 2010

I have the following two type of strings1: A/D2: A/C/DI am trying to write a subroutine to check whether all of the letters in string 1 appears in string 2. If yes, return true. If not, return false. In the above example, all the letters (A and D) in string 1 are also present in string 2, so I return true.

View 4 Replies View Related

Programming :: Convert The Int To A String Using Stringstream Then Convert The String To A Char?

Mar 26, 2011

Do I have the convert the int to a string using stringstream then convert the string to a char? or is there a more direct way?Also is there a way to tell the length of a int?

View 5 Replies View Related

Programming :: Cannot Extract Webpage For Processing

Aug 25, 2010

I am trying to extract a web page via Google for processing. I am able to create a proper query and test it using cut/paste into the address bar of my firefox browser.

When I attempt to extract the page with wget:
wget -O - -q "$query"
I do not see the information that is present when I used the browser.

View 2 Replies View Related

Programming :: Extract 2 Numbers From A Same File?

Dec 22, 2010

I am trying to extract 2 numbers from a same file and my goal is to print them both in another file, on the same line, separated with a space. I have to do that for 20 files and I would like to have therefore 20 lines like this in the output file. It would look like this :

Quote:

number1_file1 number2_file1
number1_file2 number2_file2
...
...
number_1_file20 number2_file20

So far, I did only extract one number and got an output file like this :

Quote:

number1_file1
number1_file2
...
...
number1_file20

And I did this by running a bash script with the following content :

Code:

#!/bin/bash
ls execution$1$2*.* | while read filename
do
cat $filename | grep -e "Total aborts:" | cut -d " " -f3 >> abort$1$2.dat
done

$1 and $2 are just strings to identify the different files I want to consider in this loop. This script works well to extract a number which is the 3rd field of a line starting with "Total aborts:".Now, how could I change this script to do what I mentioned above (i.e. extracting two numbers from two different lines) ? The second number is the 3rd field of a line starting with "Total throughput:"

View 7 Replies View Related

Programming :: Extract Part Of File Name?

Mar 26, 2010

I have this string ./DAT000728-652523058.job.I want to extract the no between DAT and - sign. I want 728. I dont want 000728.echo ./DAT000725-560162365.job | cut -d'T' -f2 | cut -d'-' -f1 I am getting 000728.string can be ./DAT326822-652523058.job also. then i need 326822

View 6 Replies View Related

Programming :: Extract Portion Of Text - IRC Log

Jul 18, 2011

I have a lot of files containing chat-log (IRC) and would like to extract information out of these files.

File sample

Code:
Session Start: Sat Apr 03 15:06:29 2010
Session Ident: XXX
[15:06] XXX is ~X@host-85-85-85-154.isp.be * XXX
[15:06] XXX on #channel1 #channel2 #channel3

[Code]....

View 2 Replies View Related

Programming :: Extract The Text From Files?

Aug 28, 2010

I have many files in a folder from which I need to extract some contents, these are basically text files wich have individual lines with (i.e)

name: john
address: whatever
phone: 123456

Some caveats

1. Sometimes a line might be missing.

name: johnn
phone: 123456

2. Lines are not in the same line-numbers across the files I did try some things with awk based on google searches but I couldn't extract the data of each file into a single line (this is the ultimate goal):

john,whatever,123456

I don't have knowledge other than having put some bash scripts together for backup jobs, so I am open to install anything that could to pull this off.

View 14 Replies View Related

Programming :: Extract URL From Firefox Address Bar ?

Nov 27, 2010

I'm trying to create an application that monitors, among other things, what site the user is currently viewing. I would like to know if there is any way to get the current URL from the Firefox's address bar on a Linux machine. I know that under Windows I can use the DDE server approach, but under Linux this task is proving very tricky. I've considered an approach involving an extension to Firefox, but this would require the user to install the said extension himself. Which is not something I want. If an extension can be installed by a different program's installer than that could work, but I don't know if that's possible or not.

View 14 Replies View Related

Programming :: Extract Values From Array PHP

Jul 2, 2009

The idea is to make a website to check the availability of domains and it works but its not pretty yet. Below is what i have till so far:

## this is the API from my domain registrar.
<?php $client = new SoapClient('http://api.sync.com/?wsdl');
## I have a search box that sends the request to this page
$var = $_GET ["s"];

## remove the most common subdomains from the request.
$var=eregi_replace("www.", "", $var);
$var=eregi_replace("mail.", "", $var);
$var=eregi_replace("ftp.", "", $var);
$var=eregi_replace("pop.", "", $var);
$var=eregi_replace("smtp.", "", $var);

## remove any TLD extension from the request.
$split = explode(".", $var);
$main = $split[0];
$arraysize = sizeof($split);
for ($x=1; $x<$arraysize; $x++) {
$tld .= "." . $split[$x];
}
## login to the API
$paramLogin = array('handle' => 'randall', 'password' => 'password');

## match the domain with any possible TLD
$varcom = $paramAvailDomain = array('sld' => $main, 'tld' => 'com');
$varnet = $paramAvailDomain = array('sld' => $main, 'tld' => 'net');
$varorg = $paramAvailDomain = array('sld' => $main, 'tld' => 'org');
$varbiz = $paramAvailDomain = array('sld' => $main, 'tld' => 'biz');
$varinfo = $paramAvailDomain = array('sld' => $main, 'tld' => 'info');
$vareu = $paramAvailDomain = array('sld' => $main, 'tld' => 'eu');
$varnl = $paramAvailDomain = array('sld' => $main, 'tld' => 'nl');
$varbe = $paramAvailDomain = array('sld' => $main, 'tld' => 'be');
$varde = $paramAvailDomain = array('sld' => $main, 'tld' => 'de');
$varcouk = $paramAvailDomain = array('sld' => $main, 'tld' => 'co.uk');
$varorguk = $paramAvailDomain = array('sld' => $main, 'tld' => 'org.uk');
$varname = $paramAvailDomain = array('sld' => $main, 'tld' => 'name');
$varmobi = $paramAvailDomain = array('sld' => $main, 'tld' => 'mobi');
$varin = $paramAvailDomain = array('sld' => $main, 'tld' => 'in');
$vartv = $paramAvailDomain = array('sld' => $main, 'tld' => 'tv');
$varcn = $paramAvailDomain = array('sld' => $main, 'tld' => 'cn');
$varws = $paramAvailDomain = array('sld' => $main, 'tld' => 'ws');
$varnu = $paramAvailDomain = array('sld' => $main, 'tld' => 'nu');
$varbz = $paramAvailDomain = array('sld' => $main, 'tld' => 'bz');
$varcc = $paramAvailDomain = array('sld' => $main, 'tld' => 'cc');

## this requests the domain.COM and domain.NET
$varcom;
$varnet;
?>
<div id="content">

## below prints the result
<?php
print "<html><body><pre>";
$result1 = $client->__soapCall('Login', $paramLogin);
echo "<b>Result Login:</b>
" . print_r($result1, true);

$result15 = $client->__soapCall('AvailabilityDomain', $varcom);
$resvarcom = var_dump($result15, true);
$result15 = $client->__soapCall('AvailabilityDomain', $varnet);
$resvarnet = var_dump($result15, true);

print "</pre></html>";
?>
<?php

## the returned array looks like this

Result Login:
Array
(
[code] => 200
[message] => Login succesful
)
array(3) {
["code"]=>
string(3) "200"
["message"]=>
string(20) "Domain not available"
["result"]=>
object(stdClass)#236 (1) {
["status"]=>
string(5) "TAKEN"
}
}
bool(true)
array(3) {
["code"]=>
string(3) "200"
["message"]=>
string(16) "Domain available"
["result"]=>
object(stdClass)#232 (1) {
["status"]=>
string(4) "FREE"
}
}
bool(true)
?>
## till so far it works

What I need to do is to make this ugly looking reply in to something more readable, basically if TAKEN print occupied and if free print its yours to grab. I have been struggling with the in_array function but i'm not getting anywhere close in getting it to work.

View 2 Replies View Related

Programming :: Extract Metadata From Image

Mar 13, 2009

I am trying to get the metadata out from an image file in python. I have tried using PIL but it does not give me the data I am looking for (mostly just got a bunch of hex code) and I have no idea how to use ImageMagick, the python module is poorly documented and I can't find any examples on the net.The info I need is stuff like camera model, if flash was used, focal length, exposure time, date, etc.. pretty much the same info I get when I look at the "Image" tab on properties in Nautilus on Ubuntu.

What I am doing is writing a script that will iterate through a lot of pictures and put all this metadata into MySQL. I chose python since it is simple and I am familiar with it. But I can't find a good way to get that metadata from within python.

View 2 Replies View Related

Programming :: Serial Port Programming String?

Nov 24, 2010

I have a serial port program which is reading a string .if(read(readfd,sResult,1)>0)where sResult is unsigned char sResult[10];if sResult is array of 10 then iam getting string perfectly but if iam making sResult only as unsigned char I am getting NULL value CODE BELOW

Code:
unsigned char sResult;
main()
{
readfd = open("/dev/ttyUSB0", O_RDONLY);
if (readfd == -1)
{
perror("READ: open_port: Unable to open /dev/ttyUSB0-

[Code]...

View 2 Replies View Related

Programming :: Extract Source Email Address - Awk?

Dec 17, 2010

I have a small bash/awk program that extracts the date/time/size of thousands of email headers. I'm trying to also extract the last "Received from:" string from these email headers which will give me the senders email server. on extracting the last occurrence of this string, and printing the information after it?

View 3 Replies View Related

Programming :: Awk To Extract Phrase Between Two Words On A Line?

May 25, 2010

im trying to find a way to extract the phrase between the words Connection and is (ie the underlined words below). Can we use awk to do this? How? Is it the best command to use?

Code:

[06:25:00][i] Connection at Plant A is live
[06:25:00][i] Connection at Building_C is not live
[07:25:00][i] Connection at Terminal D is down

View 12 Replies View Related

Programming :: Extract A Substring Using Regular Expression With SED

May 7, 2011

I've spent most of the evening browsing the web, trying many things I've found on various forums, but nothing seems to work.

I have a test.txt file containing many lines like the following ones :

...
<insert_random_text>228.00 €<insert_more_random_text>
<insert_random_text>17.50 €<insert_more_random_text>
<insert_random_text>1238.13 €<insert_more_random_text>
...

And I want to extract :

...
228.00
17.50
1238.13
...

There is always one occurrence of € in each line. I want the numeric value that precedes this € occurrence. The random text (before and after) may contain numbers too, so the € may be important to parse, in order to correctly identify the number to return. The last character that precedes the number to extract is always a ">" (coming from an HTML tag).

View 9 Replies View Related

Programming :: Extract The Full Name Of The Process Running In Box?

Jul 11, 2011

I have a requirement where I want to extract the full name of the process running in my box. I tired various options of ps. The wide option gave me the full command but that contains command, the interpreter and also the arguments passed.

Code:

XX XX XX XX XX XX /usr/bin/sh /path/to/exe/myexe.sh arg1 arg2 arg3.

Is there any way from ps or any other command I can extract the full name of the command

Desired Output :

Code:

/path/to/exe/myexe.sh or myexe.sh

View 12 Replies View Related

Programming :: How To Extract A Subset From A Huge Dataset

Mar 13, 2010

I have a huge file which has 450G. Its format is as below

x1 50020 A 1
x1 50021 B 8
x1 50022 C 9

[code]....

Now, I want to extract a subset from this file. In this subset, column 1 is x10, column 2 is from 600000 to 30000000. I wrote the following perl script but it doesn't work:

#!/usr/bin/perl
$file1 = $ARGV[0]; # Input file
$file2 = $ARGV[1]; # Output file

[code]...

I guess the input file and output file are both too big that my script can't handle it.

View 11 Replies View Related

Programming :: How To Extract Output Ulimit Under Popen

Jan 30, 2011

A strange question, I guess. I'm running processes called from a c main program. The calling is performed (for now) as: FILE * res=popen(ulimit -t 1; prg args); So I can read the stdout of the process as a file and analyze it. The time limit is important for me.

2 questions:
1. How do I get to know if the process terminated on its own or by the ulimit?
2. How do I limit to times that are less than 1 sec (I have many of those).

I know that setrlimit exists, just before I change my whole approach I wanted to see if I can deal with these things from the outside.

View 2 Replies View Related

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 View Related







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