Programming :: Sed (?) Insert String Between 2 Others?

May 21, 2010

I have a file like this:

Code:
/opt/local/some/dir/
blablablabiugfyugf

[code]....

View 10 Replies


ADVERTISEMENT

Programming :: How To Insert Characters Into String In Shellscripts

Nov 15, 2010

My problem is to insert one sign like space or ':' into a line or string.The goal is to get a demiliter for `cut`.I tried to do it with `tr A-Z "'A '-'Z '" and such but without success.I guess a while read loop could do it but I don't know howto use it with ` expr length $STR`

View 5 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 :: Insert A String For Different Files....complete A Sentence Only?

Mar 3, 2010

I have the following bash script:

#Add extension into the name
for FILE in $(ls $SOURCE*$1*);
do echo $FILE;

[code]...

View 12 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 :: Insert $2 Argument Until The End To Variable?

May 17, 2011

how to insert $2 argument until the end to variable?For example:

>> cucu.csh user "long long message "
$1 = user
$2 = "long long message "

View 10 Replies View Related

Programming :: Insert Data In A Nested STL Map?

Dec 13, 2010

Following is the declaration:

Code:
std :: map <QString, std :: vector <std :: pair <QString, QString> > > configFileDataVector; How should I insert data in it? All the examples which I have looked up in Google are of plain maps!

I tried this, but it failed:

[Code]...

View 4 Replies View Related

Programming :: Insert A Character In Line Using Sed/awk?

Jul 25, 2011

I have a string as below

LogFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined

Want the above string to be modified as

LogFormat "%h %l %u %D %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i"" combined

inserting %D after %u in the string

View 3 Replies View Related

Programming :: Insert Paragraph At Particular Line?

Jul 26, 2011

I want to copy below content to a file after line 200.

Alias /A/ "/A/B/C/D/"
<Directory "/E/F/G/H/">
Options Indexes MultiViews
AllowOverride None

[Code]....

Or is it possible if I can copy this content in some other file and insert to the main file.

View 4 Replies View Related

Programming :: Insert Query In Mysql ?

Jul 12, 2011

When i enter this query to mysql:

Code:

return this error:

Code:

when i delete the insert part :

Code:

query is ok:

Code:

1 row in set (0.00 sec)

View 2 Replies View Related

Programming :: Sed To Search And Insert Column?

Feb 24, 2011

I have the following file.

B0 49.2230869 -102.5743868
C 1LPRK 654.90
C 1PREU 3693.90
C 1JRSU 3693.90

[code]....

I need to insert text ABCDEF starting at position 26 if a line starts with C. I need it to look like:

C 1VKNG ABCDEF 3097.00
C 1JLFU ABCDEF 3157.20
C 1MNVL ABCDEF 3346.10

I would prefer to use sed to do this and not perl.

View 14 Replies View Related

Programming :: Insert Graphics Into Latex File?

May 30, 2011

I want to insert graphics into latex file, for longtime I used xfig to create graphs, but it is limited,specially for math formulas, dia i find not easy to use.Finally I want to try asymptote or tikz which one is more appropriate

View 1 Replies View Related

Programming :: Insert A Line In The Test File With Sed?

Jul 15, 2010

I have following file workers file: There are 800 entries like this.

# consensus/uat
worker.consensus-uat1.host=lonlx10409
worker.consensus-uat1.port=13702
worker.consensus-uat1.type=ajp13

[code]....

I want to insert one line just below the line starting with "woker.list". I think sed can do it but I am not aware.

View 14 Replies View Related

Programming :: Insert Kernel Module Into Menuconfig

Jan 14, 2011

I am looking for information to insert kernel module into kernel. I am not looking at dynamically insert of kernel module using insmod, modprobe etc. I am looking for statically insertion of kernel module procedure, such as what to change on makefile, what to change on menuconfig, what to change on .config file, etc.

View 2 Replies View Related

Programming :: Insert Text Before The First Pattern Found?

Apr 8, 2011

i need to add this line nameserver 208.67.122.221 from ISP before the first nameserver already exists in resolv.conf in all workstations i know

Code:

sed '/nameserver/ i
ameserver 208.67.122.221'

but that insert it on every line after nameserver not only before the first one

Code:

# blah blah
# blah blah
domain mydom.com

[code]....

View 3 Replies View Related

Programming :: Insert Text Message In Textarea Using Php?

Dec 13, 2010

i trying to add text messge in textarea and i got error in connection and i don't know if it correct syntax. and i wonder when i was install xamp server it no password required. but i dont know what password that i input in my php connection.?

PHP Code:

<?php
$con = mysql_connection("localhost","root","123");
if(!$con)
{

[code]....

PHP Code:

<textarea rows="3" cols="30" name="txtcomment" wrap="physical">Leave a Comment

View 4 Replies View Related

Programming :: Insert A Variable Into A Regex In Perl?

Jan 17, 2010

I was wondering if you insert a variable into a regex in Perl, will the contents of the variable be expanded by the regex engine?

View 14 Replies View Related

Programming :: Sed Insert Line With Leading Spaces?

Mar 3, 2011

I'm trying to insert a line using sed that has leading spaces before the text. Sed seems to be just dropping the spaces and only inserting the text. Any ideas what I'm missing?

Code:

NAM=rb134
sed -i.bak -e "$i
host ${NAM} {" /etc/crap

Instead of inserting a line with 8 leading spaces inserts it with "host" at the beginning of the line. I tried

Code:

NAM=rb134
sed -i.bak -e "$i
^ host ${NAM} {" /etc/crap

but it put the "^" at the begging of the line.

View 6 Replies View Related

Programming :: Insert Values Into A MySql Database?

Feb 9, 2010

I want to insert values into a MySql database. The following line works fine:1

Code:
mysql_query(connection, "INSERT INTO main (NumofShows , Title) VALUES('12', 'Home')");
but if the data to be inserted is from a string... like....
Code:
string NewTitle = "Monaco";
string NumofShows = "2";

How do i edit my sql statements so variables can be inserted into the Values ( ) , and it will be able to read the variables and then store it into the database.

View 4 Replies View Related

Programming :: Insert Elements Into A Combobox From A Database Using NETBEANS?

Apr 13, 2010

I'm trying to make a combo box which should have elements dynamically taken from a database. I've an Exam Table,and it has columns Sno,Ename,Month,year. i need the combobox to list to the elements that are present in Ename.

i read some things in the web and tried that out in the netbeans. it said to rightclick the combobox and set bind ->elements and bind->selecteditem. But i'm not sure how to set the binding expressions inorder to get the required list in the combobox.

View 1 Replies View Related

Programming :: Insert Line Of Text Prior To Pattern Only Once?

Jun 29, 2010

I have a file like so:

Code:

one
two
three
four

I would like to insert prior to the word "three" all items from this second file with the following contents:

Code:

four
three
two
one

Now my issue is, and I have been using both sed and awk currently, that after the second line of the new file is read there will of course now be 2 copies of the word "three" but I would like to only insert the final 2 words, ie "two" and "one" prior to only the first occurrence of the word "three" so final file will look like:

Code:

one
two
four

[code]....

So here there is now only one of each word from the second file joined to make the new file. For simple code I have tried something like the following:

Code:

while read line
do
awk -v n=$line '!f && /three/{print n;f++}1' file1 > tmp_file
mv tmp_file file1
done < file2

Now this works but seems very clumsy to me. There is obviously a better sed and / or awk out there.

View 5 Replies View Related

Programming :: Script To Insert Characters At End Of Basename In A Filename

Aug 19, 2010

Enterprise Linux 4 (2.6.9-78 kernel)...rename not working! Need to insert "_T" at the end of every file in a directory, just before the ".extension"

I have tried sed substitution with no success (because I do not know the codes and effects of anchoring well enough).

An example filename:

My failed tests:

Code:

Code:

Code:

Code:

View 9 Replies View Related

Programming :: Sed To Read The File And Replace And Insert The Pattern?

Jun 11, 2009

I want to read from the file and check for the pattern, if the line has some word like <string>: then string should be copied into buffer. Afterwards, I want to insert the same <string> with some word in the next line of the file. use sed command to perform the above mentioned operations?

View 2 Replies View Related







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