Programming :: Get Search Results To Array By Awk?
May 5, 2010I have this multiline variable code...
View 5 RepliesI have this multiline variable code...
View 5 Repliesi have a loop which produces new value everytime it runs. i want to store the results in an array. how can i do dat??
loop is like:
a=0
declare v
while ((....))
do
v[$a]="$r"
let a=a+1
done
while doing this it is not treating v as array but as variable and it is overriding the value and old value is lost..i am using bash shell version 3.00.15
I have data that looks similar to this -
Quote:
John Smith (Address)
123 Main St
Unit 1
[code].....
So I need everything between each name, but I am not guaranteed that each time I match a name that I will have the same amount of lines, so I do a range pattern search line this to get all lines, no matter if there is 5 or 10 or 15. I simply do a loop that goes through the whole array until I hit the match, and this is my search pattern.
Code:
if ($LINE =~ /^s+$SELECTED_NAME/ ... $LINE =~ /(Address)/) {
push @ADDRESS_INFO, $LINE;
}
This works perfectly... until I hit the end and it doesn't get its final pattern match because it's at the end and there is no next entry with a (Address) line. So as a 'hack', I ended up inserting a final scalar at the end of the array that just says (Address) so it knows it's at the end. Ideally though, I'd like to do an "or" statement that says search for Address || return true if I hit the end of the array. How would I match on "End Of Array" essentially?
how I can search within a variable and assign the results to a new variable. I'll use the following as an example -
cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`
with the echo command I get the following output assigned to list -
A
C
C
What I'd like to get for output is -
Audi
Cadillac
Chevy
how I could do this regardless of upper/lower case letters?
After i try to find logfiles follow date/month/year. i want copy this files to another directory with name's directory is time you find(date/month/year).
View 4 Replies View RelatedI've just installed OpenSUSE. I've never used it before. I typically use apt-get to install applications when using Ubuntu; so I'd like to use it with OpenSUSE. I've read some documentation saying that I need to go to YaST -> Software and search for "apt" or "synaptic." However, both of these searches yield no results. Additionally, using the Software Manager to search for these yields no results. What can I do? When I search for something in OpenSUSE and there are 0 results, I get HTML bold tags around the search criteria where it says there are no results (as in, I can actually see the code for the bold tag).
View 9 Replies View Relatedhaving only one instance of my search results
View 5 Replies View RelatedOpen synaptic. Type in the word "Game". Then you have to scroll down through the list of results and mark each one, individually. Is there any way that I can simply mark ALL the results of the search? There is an "Unmark all" button. Can we get a "Mark all" button? It would have to mark only those packages that currently appear in the right hand box.
View 3 Replies View RelatedUpon a while of searching, I think I failed to find the correct terms and I'm posting here. I often use mlocate to search for files. For example, if I say
Code:
$ mlocate temp_2.pdf
I'll get two results:
Code:
/home/kmc/Documents/latex/temp_2.pdf
/home/kmc/Documents/latex/test/temp_2.pdf
Now if I want to open one of them, I'll have to either open Acroread and browse to their locations. Or select and copy, and call acroread in terminal like
Code:
$ acroread /home/kmc/Documents/latex/temp_2.pdf
This is tedious to me. I'm thinking of a way of quickly open its search results, I've tried pipes like this but it doesn't work:
Code:
$ mlocate temp_2.pdf | acroread
maybe it doesn't work this way. So what does the trick? What's the name of this trick? I've googled for
Quote:
Linux bash catch output, pipe output, open mlocate results And is it possible to handle multiple lines of output, e.g., can I choose which line of output get forwarded to relative programs?
I am using Files and Folders search application in Ubuntu 11 recent version. App that shows up on side. However I am not sure how clean its search result. I do not see any option.
View 2 Replies View RelatedI'm running Ubuntu 11.4. I've played with different versions of Picasa, installing the Linux version via Ubuntu Software Center and also using Wine. At a certain point I had several versions of the application installed and things were getting. When I search for Picasa in the Unity application search field (clicking the button with the dot in the centre at the top left of my screen) I got several results for Picasa, some of which when clicked would start Picasa and some which wouldn't. When I remove all versions of Picasa both from Wine and native I still get some results for Picasa which don't start Picasa when clicked.
View 2 Replies View RelatedI've just upgraded to 11.04 and really like it so far, everything seems to be running smoothly and I had no issues apart from a broken Emerald which I removed (and installed compiz-gnome and then made gtk-window-decorator the default, which fixed Unity segfaulting on Emerald).
My problem now is that when I use the Unity dash to search for something, it takes a while to search and then finds nothing. I'm pretty sure I should have things like "text editor", "gimp", "update manager", so I would think this is some manner of bug.
In addition to that, the following buttons don't do anything if I click on them:
- Media Apps
- Internet Apps
- More Apps
- Find Files
I am trying to dynamically delete and add information into the array "blah"
Code:
int blahsize = 1;
char** blah = (char**) calloc(blahsize+1,sizeof(char*));
Adding information:
Code:
blah[1]=stuff1;
blah[2]=stuff2;
code....
I have trouble converting a short array to a char array
Code:
short pShort[4] = { 0x41, 0x42, 0x43, 0x44 };
How to convert this to a char array?
I'm writing a PHP program. I've encountered a problem; in the following code I try to pass $_POST['delete'] which is an array as the value of a hidden input to some form, but it doesn't do so.there's something wrong with converting PHP array into HTML array. I'm sure that $_POST['delete'] is not null and is a real array.
echo '<input type="hidden" name="delete[]" value="'.$_POST['delete'].'" />';
(I am using vector() and matrix() functions from "Numerical recipes in C".)There are 100 numbers to be stored in 2D array of 10 rows and 10 columns.100 numbers are stored in a 1D array.I get "segmentation fault" at the line indicated in the segment of my code below:
Code:
:
:
#define size 100
#define nl 1
[code]....
I looked on the net for such function or example and didin't find anything, thus after having made one i guess it would be legitimate to drop it to see what others thinks of it.
#!/bin/bash
addelementtoarray()
{
local arrayname=$1
[code]....
consider these lines of code and their outputs:
[CODE]
int C = 0;
fprintf(stdout, "
(C, ++C) Bef = %d, Aft = %d
", C, ++C);
fprintf(stdout, "(C++, C) Bef = %d, Aft = %d
", C++, C);
[Code].....
The only one that looks right to me is the second one. I get similar results using both gcc and g++.
I wonder why arrays in the C programming language are pointers to the first element of the array, not the first element of the array itself?
View 14 Replies View RelatedIm having problems with this little thing in a C example Im doing. I want to show in the shell like this example:
Name Birthday
Tomas 13
Adrian 24
Nate 15
Im trying to use the printf function but the names doesnt have the same lenght. So I cant do it like this:
printf("Name Bithday
");
printf("%s %d
");
I have a socket library that I tinker with from time to time. Lately, I decided to expand it to support IPv6.
One of the issues I am having is sending data, using sendto(). When the server receives data from a client, using recvfrom(), it does not retain the sockaddr_in information, but instead provides the callee the IPv6 address and port number from where the data originated. See here:
Code:
int
UDPSocket::recv(char* buffer, size_t bufferLen, std::string& sourceAddr, unsigned short& sourcePort)
{
sockaddr_in sin;
socklen_t sinLen = sizeof(sin);
[Code]....
I've a web page where I can search information in my database.Sometimes results of search operation are more of fifty.How can I split results in different web page as it happens for example in any search engine or operation
View 7 Replies View RelatedI have a simple class that encrypts strings. It seemed to be working fine until I tried to compare the decrypted values to the original. below is the output of the php code. It appears to be decrypted but the length is incorrect.
String Before Encryption: a text string
String Length Before Encryption: 13
String After Encryption: rew2iSYotruIpmJ3llos3A==
[code]...
I'll post the entire code here, and then specifically highlight what is just failing in a fashion I'm apparently incapable of fixing a few hours later:
Code:
#!/usr/bin/expect
# The script should be called with a file in the directory called sshServerList
# That file has the following format:
# Line # | Contents of line
[code]....
I've had all kinds of different results and problems, but I've never been able to successfully log into multiple servers, though the first server in the list most times works okay (though might not on this iteration). I'm a bit hack and slash and I would be very greatful not only for a solution, but any tips on how I should have done this and places where I could clean up my code.
How do I find for example the 4th to the 9th result in a particular SELECT query?
View 6 Replies View RelatedI'm sure this has been covered somewhere before, but I couldn't find anything and so figured I would post here. I have been using Linux OSes for the past couple of years and also using GCC/G++ for application development. However, I have almost always been on x86 systems and never gained much experience using the wide range of optimization options available.
My question is, if I do not specify the -march=PROCTYPE option, will GCC still be able to detect the current architecture and build the code accordingly? I primarily ask this because I am working with an x86_64 system, and specifying -march=x86_64 in my makefiles generates errors about it being an unknown processor type, even though the CPU and OS are X86_64. I know this sounds like a newbie question, but it's just ground I've never had to cover before until now.
trying to see IF i dont get the right results repeat the command until it will or quit after 3 tries....
expect -exact "->"
send -- "test_read_register 0,0x37
"
if {! [regexp {Address 0x00000000} do send -- "test_read_register 0,0x37
[code]....
It should read
Read: Address 0x00000037, Data: 0x0000000b
but sometimes it comes out to this
Read: Address 0x00000000, Data: 0x00000000
therefore ill have to run the command again IF I Dont get the right results...
I am having trouble with encryption/ decryption program. The program goes out and finds the file I want it to, encrypts it into a continuing series of a single repeated negative number, then generally decrypts(or should i say re-encrypts)it into a widely repeated character, different but same results every time.
[Code]....
I ran the command:
Code:
ls -ltr | head -n40
I'd like to delete all the files listed...
I am querying a single string column in a table. The string values have spaces in them. I want to loop over each value in bash. I set IFS to split lists on newlines instead of spaces. When I try this, it is splitting the list of results on the actual character 'n', not the newline ''.
DATA=`mysql -u root -ppassword --silent 'SELECT name FROM table_a;'`
IFS=$'
'
for i in $DATA; do
echo "item = $i"
[Code]....