Search file for string and store last result to variable
Hi,
I'm trying to search a text file for a string: "energy(sigma->0)=". To do so, I executed the grep command, which returned many matches, for example:
What I want to do is store the grep results to a variable (var1), then get the very last number in the very last string result (the last number in var1), and store it to a second variable (var2) for later use in bash.
Alternatively, if there is a better command than grep that can automatically return only the last search hit in a given file, that would be even better.
Any assistance would be greatly appreciated!
gwr
Last edited by Franklin52; 01-28-2011 at 03:32 AM..
Reason: Please use code tags
:)
Suppose,I have one table A. Table A have one column. Table A have 10 rows. I want this 10 rows store into shell script variable.
like
#!/bin/ksh
v_shell_var=Hi
here in call oracle , through loop How can I store table A's 10 rows into v_shell_var (Shell Script Array).
Regards,
Div (4 Replies)
Dear all,
I have a file having the following formats:
ThreadFail=Web1=1234
ThreadFail=Web2=2345
ThreadFail=Web3=12
ConnectionFail=DB1=11
ConnectionFail=DB2=22
The number of lines will be different from every time . How can I parse the file and store the result to an a array inside... (6 Replies)
Hi, guys. I have one question:
I need to search for a string in a file, and then extract another string from the file and assign it to a variable.
For example:
the contents of the file (group) is below:
...
ftp:x:23:
mail:x:34
...
testing:x:2001
sales:x:2002
development:x:2003
...... (6 Replies)
Hi,
I have a problem that I am sure someone will know the answer to. Currently I have a script which returns a binary output if it finds a certain search string (in this case relating to a DRBD cluster) as follows:
searchstring="cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate"
&& echo... (3 Replies)
sorry i'm newbies c programer
how to store string to variable with value flexible.
example
int hh=1; ---> value flexible 1,2,3,4,5;
int xx=1; ---> value flexible 1,2,3,4,5;
char test="value=%d and value=%d",hh,xx; --> not working
char test2="value2=%d and value2=%d",hh,xx; --> not... (1 Reply)
In a directory i have a file *output* whose contents are changing for every simulation.
zgrep "trace file is" *output* | zgrep g
o/p: trace file is Int_01.1352176388z4f56ec33.0.trace.gz
I want to extract "Int_01.1352176388z4f56ec33.0.trace.gz" from the above result into a variable.
i... (2 Replies)
I can not figure out how to capture the $filename variable store by the bash.
#!/bin/bash
# oldest folder stored as variable for analysis, version log created, and quality indicators matched to run
dir=/home/cmccabe/Desktop/NGS/test
find "$dir" -maxdepth 1 -mindepth 1 -type d -printf... (5 Replies)
Hi,
I have a working script.
It does what I am intending it to but a bit confused whether the sed part is supposed to be working or not. Further down is the script with the sed part that should have been working but not and the grep -v part which is the workaround that I am using at the... (10 Replies)
Discussion started by: newbie_01
10 Replies
LEARN ABOUT SUSE
tracker-search
tracker-search(1) User Commands tracker-search(1)NAME
tracker-search - Search all content for keywords
SYNOPSIS
tracker-search [OPTION...] EXPRESSION [EXPRESSION...]
DESCRIPTION
tracker-search searches all indexed content for EXPRESSION. The resource in which EXPRESSION matches must exist (see --all for more infor-
mation). All results are returned in ascending order. In all cases, if no EXPRESSION is given for an argument (like --folders for example)
then ALL items in that category are returned instead.
EXPRESSION
One or more terms to search. The default operation is a logical AND. For logical OR operations, see -r.
OPTIONS
-?, --help
Give a short help message.
-l, --limit=N
Limit search to N results. The default is 512.
-o, --offset=N
Offset the search results by N. For example, start at item number 10 in the results. The default is 0.
-r, --or-operator
Use OR for search terms instead of AND (the default)
-d, --detailed
Show the unique URN associated with each search result. This does not apply to --music-albums and --music-artists.
-a, --all
Show results which might not be available. This might bebecause a removable media is not mounted for example. Without this option,
resources are only shown if they exist. This option applies to all command line switches except --music-albums and --music-artists.
-f, --files=EXPRESSION
Search for files of any type matching EXPRESSION (optional).
-e, --folders=EXPRESSION
Search for folders matching EXPRESSION (optional).
-m, --music=EXPRESSION
Search for music files matching EXPRESSION (optional).
--music-albums=ALBUM
Search for music albums matching ALBUM (optional).
--music-artists=ARTIST
Search for music artists matching ARTIST (optional).
-l, --images=EXPRESSION
Search for images matching EXPRESSION (optional).
-v, --videos=EXPRESSION
Search for videos matching EXPRESSION (optional).
-t, --documents=EXPRESSION
Search for documents matching EXPRESSION (optional).
-e, --emails=EXPRESSION
Search for emails matching EXPRESSION (optional). Returns a list of subjects for emails found.
-c, --contacts=EXPRESSION
Search for contacts matching EXPRESSION (optional). Returns a list of names and email addresses found.
-V, --version
Print version.
SEE ALSO tracker-store(1), tracker-stats(1), tracker-tag(1), tracker-info(1).
GNU July 2009 tracker-search(1)