One of my application generates a text file with an XML output in it. I need to read that log files and if the output does not match to a string in couple of tags it should create a log file with the file name and the the tag name.
The two tags where the string should match is:
Identity format tag should always be JPEG , well- formed and valid status tags should be true.
What is the best way to merge lines, in sed, awk or perl, that occur between certain strings? I'm new to sed scripting and I have been working on this for some time now. I have a large file (sample below) that I need to edit.
What I need looks something like this.
I'm working with a very large file so simply merging all the lines then adding a new line character before ">contig" and after "translated" won't work, at least not with sed.
I am new to perl and am having trouble adding some strings together.
My full code is below:
The problem is $NewCommandB is always split into two lines, where the second line contains the "/atlas2/<blah>/<etc>/..." string. Since I am generating a .sh file to execute a lot of similar commands I need the string to all be on one line. Any idea why I get this behaviour and any suggestion on how to tell perl to make $NewCommandB a one line string?
Btw for completeness finalFileList.txt contains just file names one line after another:
I wanted to find and replace a string from a perl file. I have written a script in bash which runs the following command.
perl -pi -e "s/$findstring/$replacestring/" testfile where as $findstring = print F_WC_TMP"$line "; and $replaceString = $line = join ' ', split ' ', $line; print F_WC_TMP"$line ";
But when I am running the above command, i think it is replacing the $findstring with the above mentioned string and hence it contains a $line, it is looking for the variable $line and not finding the exact string. I am confused about how to search for a string that contains $ in it and replace it with another $string.
I have searched and searched in regards to this documented 'special expression '-l STRING' for the 'test' command, and to no avail, have I found out why it does not work on my system.
The example always given is: Code: test -l abc -gt 1 && echo yes And the returned result is: Code: bash: test: -l: unary operator expected The documention is usually as follows: Numeric tests
Numeric relationals. The arguments must be entirely numeric (possibly negative), or the special expression `-l STRING', which evaluates to the length of STRING. Then examples are given, including the one I provided above. Does anyone else have this issue of getting an error when trying this special expression of 'l STRING' ???
I have script that I'm working on that updates a username in all the files that are called blah.inc for my framework. since i host a bunch of these web apps i need to do it to all of them. so I need to figure out how to update these files automagically with out me watching it to call vim every time. heres what I have so far
This finds the files but now i need to figure out how to do s/bob/fred/g on those files.
The below snippet works fine until I use strict. Then it dies with the following error: uote:Can't use string ("html") as an ARRAY ref while "strict refs" in use at ./filetest3 line 18.I want to create @lists based on the $scalars in @type. However, "my @$ext = ()"; and push (@$ext, @files); do not play nice with strict. How do I get around this?Quote:
I am trying to write a bash script that will extract a .cbr (.rar) file, traverse the extracted files in alphabetical order and rename them 001.JPG, 002.JPG, 003.JPG, etc.So far I only have this much to extract it:
I'm looking for a script which is testing how complex an "added" string is, for example like the user is changing his password and check how complex it is, if it included letters (lower/upper case), numbers and other characters.Im doing this for password check, the user type's the password and must be 6 characters long, have upper case letters lets say and numbers and so on.If anyone knows where I could find some bash script which is doing this, it would be really cool.
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.
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.
In Perl. I can't find the global variable for $_ (except not $_ it's the one to specify AFTER the matched string.) its dollar sign then something else. Does anyone have a cheat sheet for global symbols?
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?
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.
I want to know the Perl command to replace a string by pointing the line number. I know how to replace a string without pointing a line number but I am in need to replace only the two matching string in a file
is it possible using a perl script to test for a socket listening on a UDP port on a remote host ?I work in an environment where netcat is not allowed and from time to time I need to see if a UDP port is open on a remote host.
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)