Programming :: Put String On Top Of Text?
Jul 28, 2010
I want to create a script wherein it will put a string somewhere on the text file. I tried to create a script using redirect ">" and then put it on top of the file.
The text contains code...
View 6 Replies
ADVERTISEMENT
May 26, 2011
I want to know how can I add something to a specific line.. the output would be something like:
abc
def 123
ghi
Search for string "def" and add something to that line.
View 1 Replies
View Related
Feb 3, 2010
I am using C. I have a fuction that returns a string
Code:
I need to format this string so that I can create a text file like so:
So I'm trying:
Code:
But I get errors like:
View 2 Replies
View Related
Jan 25, 2010
im tryin to make a tool in visual C++ which will take an input string through a text box,then it will compare tht string with a text file containing data and display the matched results in list box.
View 2 Replies
View Related
Sep 24, 2014
I am having trouble writing a script that monitors a text file. When the file contains number 1 (or any other string that is not a command) it does nothing, but when it is something different from 1, it executes that command.
So, there are 2 files: monitor.mon - this is the file that will be checked constanlty; and test.sh - the script that does the job. The monitor.mon file will have its content modified by php. This means a web page will have a form where I input commands and writes does commands in the file. Test.sh will watch when the file's content changes from character 1 to a command, execute that command and write back a 1 so it will not execute it more times.
I tried combining while and if but with no success. Tried reading the file with cat and grep -e but it doesn't seem to recognize when content changes.
View 4 Replies
View Related
Apr 17, 2011
write such script (bash script). I have some text file with name filename.txt I must check if this file contains string "test-string-first", I must cut from this file string which follows string "keyword-string:" and till first white-space and save it to some variable.
For example. File: PHP Code: PHP Code:
Start 15022011 Eng 12-3-42
SN1232324422 11 test-string-first
SN322211 securities
HH keyword-string:123456321-net mark (11-22)
[Code].....
View 1 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
Mar 29, 2011
Here is the issue. I am reading in a outside text file and putting in the string on that line into a char array that is already allocated.
Code:
int main(int argc, char *argv[])
{
[code]....
View 1 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
Sep 2, 2010
I have a line in a text file that has 40 random characters within a tag and i want to change the characters to a new set of 40 random characters (alphanumeric a-z 0-9 etc)
The line in the text file looks like this:
Quote:
How would i go about doing that?
Also second question same as the above but how would i remove them instead of replacing them?
View 14 Replies
View Related
Apr 26, 2011
If I have a word in a text file and I need to replace it by another word (for example, i need to replace abc by fff) so what is the command I can type it?
I am using vi editor.
View 3 Replies
View Related
Sep 29, 2010
Suppose I have a file named temp.txt
cat temp.txt
word/one/two/three
If I would like to replace "one" with "six" I would do this:
cat temp.txt | sed 's/one/six/'
word/six/two/three
Now I want to replace "one/two" with "six/seven" and these options don't work:
cat temp.txt | sed 's/one/two/six/seven/' (OFCOURSE)
cat temp.txt | sed 's/"one/two"/"six/seven"/'
I even want to be able to replace "one/two" with "six/seven/eight"
View 6 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
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
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
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
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
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
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
Sep 24, 2009
I'm writing a centralized logging piece, and I need to grep out logs that have specific date tags. The date command returns abbreviated months (Sep), via "#date -d yesterday '+%b'" but I need it all caps. ie SEP vice Sep. Otherwise the grep doesn't catch it
View 3 Replies
View Related
Apr 28, 2011
Q: Is there any way to use grep and sed with a string variable rather than with a file?
The problem: Im running through a LARGE (about 10,000 lines) xhtml file and need to replace every instance of lines beginning <p>~
The following code works but takes a long time mainlly because an in/out operation needs to be carried out on each line. If I could read from a string rather than a file it would take a much shorter time!
Code:
#!/bin/bash
count=$((0))
>tpf
echo "waiting....."
[Code].....
View 4 Replies
View Related
Oct 27, 2010
In the past, the filebrowser (nautilus) had a navigation-field with the pathway as text , but now there are buttons. I wonder how I can get back to the old-way.
View 2 Replies
View Related
Mar 3, 2011
Is it possible to search ALL files on a system for a specific text string? I've been messing around with grep without any luck.
View 2 Replies
View Related
Jun 5, 2009
I have a text file which include code...
I mean, this string should be removed from each line and save in another file.
View 9 Replies
View Related
Feb 1, 2011
When I press the power button and select 'Hibernate' I get a text string come up on the screen. The last characters are "fail: -6". There is more to it but it's there and gone so quickly I haven't written the rest of it down yet. What this might be?
View 3 Replies
View Related
Apr 29, 2010
Assume I have a text file as belowabcdaaaaaaagfgkhahahahahahhahhgfThen gf would be returned
View 4 Replies
View Related
Oct 27, 2010
I'm trying to search all .log files in ~/.irssi/irclogs/ and it's sub directories for the string 'irssi' and I had though the command I'd used for something similar before was.How should I edit the command, and is it possible to output every line found containing the string to file?
View 4 Replies
View Related
Aug 2, 2011
I have a file called Regions.ini that looks like this:
Code:
[Granite]
RegionUUID = 54ab7cd2-0e70-49b7-8020-8dbeb84c08d0
Location = 9991,10007
InternalAddress = 0.0.0.0
InternalPort = 9001
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9
[Syenite]
RegionUUID = 8fc56fdd-0afd-4074-9432-0ae8f42b799f
Location = 9992,10007
InternalAddress = 0.0.0.0
InternalPort = 9000
AllowAlternatePorts = False
ExternalHostName = 71.171.21.9
What I need to do is find out what the IP address is after "ExternalHostName ="
After that I will need to compare that IP to whatismyip and if it's different then replace it but that is easy to do with sed. I just can't figure this simple hurdle out.
View 12 Replies
View Related
Mar 6, 2010
I have a series of file names in a text file that I generated by running
Code:
bash-4.1# ls -alt *.txz | awk '{print $8}'
and then copy pasting the output. All of these file names have the version number
Quote:
-4.4.1-x86_64-1alien.txz
I just want a method to remove that version number from all the filenames so that I can then add all the packages without version numbers to a blacklist file.
I've tried kwrite and mousepad and both have a search feature and a replace feature but I haven't been able to just have the text removed successfully.
View 3 Replies
View Related
Feb 1, 2009
dose any one know the text string to enter to DISABLE ip v6 100% during the install?using the gui installer for fedora 5,6,7,8,9 i have been able to disable this ( uncheck a check box) then set the system up manually for ip4 .the reason is for some reason if ip6 is on during the install ( i have had this problem with all versions of fedora f5 through 9 and now 10)then fedora will never, never, NEVER ever connect to the net .the ip6 lookup kills my cable box, i boot into windows and it can not even connect until i unplug the box for 2 min and plug it back in and get a NEW/renewed ip address .so i do believe that i am going to need to do a text install and disable ip6. But the question is HOW ?
View 3 Replies
View Related