Programming :: Write A Function That Counts The Number Of Occurrences Of A Pair Of Letters In A String?
Sep 9, 2010
Some help with this problem:Code:Write a function that counts the number of occurrences of a pair of letters in a string
View 13 Replies
ADVERTISEMENT
Apr 29, 2010
How do I find a string in files in a directory. And these file names begin with letter a. I also want to get the number of occurrences of this string from the grep I run.
I tried this:
cat * | grep -c string but it searches all files. I just want to search files that begin with letter a
View 5 Replies
View Related
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
Mar 30, 2010
I want to use SED to do the following: In a text file replace any occurrences of the three character string ZZZ with a quotation mark "and. replace all occurrences of a comma with a semi-colon. It is the S/ / / command which is stumping me on the first issue...inparticular how to get the replace string to be quote.
View 9 Replies
View Related
Nov 21, 2010
I have:
Code:
C:u002Cdatau002CDocuments
If I used:
Code:
sed 's/u0052//'
It only removes the first occurrence. How can I remove all occurrence in the line?
View 5 Replies
View Related
Jun 2, 2011
i try to make a script in bash that u choose a number for example 501 and another number like 1 and find how much the 1 number repeat in all numbers from 1 to 501 for example 11 -->1 repeat 2 times.in 1 to 501 the number 1 repeat 200 times.
View 4 Replies
View Related
Aug 19, 2010
Is there any inbuilt function other than strncmp which can evaluate a string.my requirement is " if all 10 values are spaces print 1 else if it contains some values print 2 else print 3.if i use strlen, even space is counted.I know that i can evaluate using for loop by checking 1 by 1 char, and using strcmp function, is there any other way?
View 2 Replies
View Related
May 30, 2011
Say I have a file as
[code]....
It would be great, if i could issue a command (Vi/Bash/awk, ...) in order to obtain
[Code]...
So, the "replace string" should be replaced by another string containing the counter of replacement.
View 7 Replies
View Related
Jan 26, 2011
How do I count the number of occurrence characters in a string in an efficeint way ?
How do I reverse the words in a string with out using temp variables if possible . (if not possible use temp variables ?
Why do I specify dependedcies for header files in the Makefile ?
View 2 Replies
View Related
May 30, 2010
Can you offer me the code about fmod() in C. I want to know how this function work, i am very interested in it because i have no idea to implement it, i want to know... how to write the function... not 'how to use the function' can anyone post the source codes of this function here?
View 6 Replies
View Related
Apr 10, 2010
I have a very large data file, with 3 numbers in each line, ex. 3 4 5 ; 6 7 8.I want to add two numbers (0 and 1) at the end of every line, and a string at the beginning of the line. Does anyone know a efficient way to do so?
View 7 Replies
View Related
Sep 22, 2010
I need a help regarding writing a function in a shell, what exactly a function does!!
View 3 Replies
View Related
Sep 1, 2010
I want to write a function that shall execute periodic. means if i set time 1 sec that function should execute in each 1 sec. let us call that function func1. But i dnt want to wait inside the func1 for that 1 sec. Meanwhile i want to run another function say func2 in background . some thing like less priority function. Whnever the time come to execute the periodic function func1 it has to go to func1 and then again in the waiting time , the second function func2 will resume. I wanted to know how to do it.. Can somebody tell me is it possible using signal in linux.
View 6 Replies
View Related
Dec 15, 2008
I need to write a script which will get a number from STDIN and then with that number echo a set number of questions (its for a firewall config). Heres what I want the user to receive.
How many ports do you want open? 3
1. specify port: 80
2. specify port: 21
3. specify port: 23
In the background this will echo a command out to a text file which will read as follows:
open port 80
open port 21
open port 23
I've done this before but I've completely forgotten how
View 2 Replies
View Related
Dec 10, 2010
How do I write a regexp that matches a string that begins with whitespace or contains a newline, but not necessarily both?
View 2 Replies
View Related
Jan 21, 2011
I'm trying to write some code that involves creating a function to return a vector iterator.I'm not sure what is wrong.
Code:
template <typename T> class VectorTemplate
{
[code]....
View 4 Replies
View Related
Feb 21, 2010
the function terminates if no key is pressed for 10 consecutive seconds. I tried using the -t option as suggested in some forums, but my version of showkey doesn't have the option of changing the timeout. The options I get are:
-h --helpdisplay this help text
-a --asciidisplay the decimal/octal/hex values of the keys
-s --scancodesdisplay only the raw scan-codes
-k --keycodesdisplay only the interpreted keycodes (default).
Is it possible to write a script to use this function and still keep the function active until an interrupt is recieved?
View 6 Replies
View Related
Oct 22, 2010
copy string a to string b and change string b with toupper() and count the chars
View 3 Replies
View Related
Aug 12, 2010
I am trying to strip the numbers from the 5th columns and just get letters - in perl - i tried using subsrt, chop. and a regex -
what i want to get is:
i tired appending a regex perl -nle 'print /(w{1,20})d{1-20} but it did not work.
View 5 Replies
View Related
May 13, 2010
I ran into it while google Segmentation Fault. I'm writing a simple C program that reads a file that counts each line and numbers it then writes to a file called sdout. I copyed my program mostly from the text book but im still having problems. Heres my code:
#include <stdio.h>
#include <stdlib.h>
void new_line(FILE *, FILE *);
int main(char *argv)
[Code]....
View 14 Replies
View Related
Apr 15, 2011
I'm trying to process a postscript file and I want to change alternate pages by finding the string '%%EndPageSetup' (and then adding a line after it).
I've tried using sed with labels and a branching program to ignore the odd occurrences and process the even ones. In the code below I tried searching for the first and ignoring it by jumping to next and processing it and then to the next odd page and so on.
My logic is obviously flawed here as it doesn't work but I've tried the following:
Code:
#!/bin/bash
sed -e '/%%EndPageSetup/{
b even
:odd
/%%EndPageSetup/ b even
:even
s/%%EndPageSetup/%%EndPageSetup++/ b odd}' filename.ps > newfile.ps
View 5 Replies
View Related
Dec 14, 2010
I'm programming some skript to get statistical information about some texts. This includes calculating the mean of word lengths.Unfortunately, Umlauts count as two characters. In the example below the output is 9, it should be 6.
sincercly, Max
Code:
#!/usr/bin/perl
use POSIX;
use locale;
my $test = length("ABC���");
print $test;
View 4 Replies
View Related
Dec 15, 2009
Here's the actual line of code, which exists in a bash script:
Code:
I want to replace instances like this:
Code:
with this:
Code:
Using this:
Code:
Which works great when there's only ONE of the pattern on the line. But in a case like the "actual line" I posted first, where there are two patterns, separated by a slash, only ONE gets replaced
Watch:
Code:
Why? There must be (among many other things) something I'm not knowing about sed, that's causing this.
-- I'm currently using the ~ (tilde) as the separator in the sed command. It doesn't matter, I've used / ~ and % with no difference.
-- As a test, I tried putting a different character(s) in the middle of the original pattern instead of the / but that made no difference.
-- I've come up with various similar but slightly different regexs that will do this replacement, but they all have had this same result.
-- I tried the sed single-quoted, double-quoted, and unquoted; the latter fails to execute, and the formers both work as described here: wrong.
View 7 Replies
View Related
Dec 15, 2010
How to setup the environment for remote pair programming session on Ubuntu (10.10) securely over the internet?
I think that, for our workflow, we need to share the screen, sharing terminal session or text editor alone would not be ehough. Note that I mean equal rights sharing, where both clients have full access to the keyboard and mouse.
Along with the shared screen we need to have a voice (and, maybe, text) chat working. Skype is OK.
View 2 Replies
View Related
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
Nov 16, 2010
Code:
#include <iostream>
using namespace std;
[code]...
View 1 Replies
View Related
May 18, 2010
I am doing some Linux kernel programming for my research project. I need to record the timestamp (by using cpuid and rdtsc) when an interrupt handler (top half) is first invoked. Due to the time critical nature of the problem itself, I have to do the timestamping inside the interrupt handler itself (the first operation when the handler is called). However, I understand that tasks that are not so time critical should be deferred to a tasklet function (bottom half) for processing because other interrupts are disabled in a (top-half) interrupt handler. I am currently out of idea on how I can pass the timestamp information that I have obtained in the interrupt handler to the corresponding tasklet function.
View 2 Replies
View Related
Jun 8, 2010
I want to convert strings like 002, 049, 050, 100 to numbers: 2, 49, 50, 100.
I tried to use:
Code:
`printf "%5d" $i`
, but it doesnt work , it convert:
002=>2
014=>12
049=>0
View 11 Replies
View Related
Sep 12, 2010
I am trying to replace the first number in a string at the end of the line with the word that matches that number. for example i want to replace 546215 to be five-46215. The command that I have tried is
sed -r 's/5[0-9]{5}$/five-[0-9]{5}/'
View 3 Replies
View Related
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