How to find a value from an expression?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to find a value from an expression?
# 1  
Old 10-18-2016
How to find a value from an expression?

I have below expression from which I would like to output +m= value:
"
Code:
ginger bread.k +log ../output1 -format +m=3 0 +sleep 10 +suspend 10

"
The output value should be "3" Any suggestions?

Last edited by Scrutinizer; 10-19-2016 at 12:06 AM.. Reason: code tags
# 2  
Old 10-18-2016
Code:
echo 'ginger bread.k +log ../output1 -format +m=3 0 +sleep 10 +suspend 10' | sed 's#.*[+]m=\([^ ][^ ]*\).*#\1#'

# 3  
Old 10-18-2016
With shell script you could also use:

Code:
$ S='ginger bread.k +log ../output1 -format +m=3 0 +sleep 10 +suspend 10'
$ V=${S#*+m=}
$ echo ${V%% *}
3

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to find regular expression for two files?

I have files: sum_<INPUT FILENAME>.YYYYMMDDhhmmss.csv and sum_details_<INPUT FILENAME>.YYYYMMDDhhmmss.csv I have no idea, what is input filename, but in the code I would like to catch them in case I process them in the loop above case statement for *.${Today}.*.txt... (3 Replies)
Discussion started by: digioleg54
3 Replies

2. UNIX for Dummies Questions & Answers

How to using Regular expression to find file.?

Hi Gurus, I need to identify the file with below format: ABC20110101.DAT ABCD2011010103.DAT If I use ABC*\.DAT, it get two file. I want to get file after "ABC' then number, the ".DAT". I tried ABC* but it doesn't work. Thanks in advance. (9 Replies)
Discussion started by: ken6503
9 Replies

3. UNIX for Dummies Questions & Answers

find command: names matching the expression

Hello all, I need to print directories using find command. The directories names contain date in the format YYYYMMDD or the name of directory is only the date format. I want print directories, which doesn't start with this date. E.g I have dirs like foo20120101 foo20120101foo 20120101foo... (1 Reply)
Discussion started by: satin1321
1 Replies

4. Shell Programming and Scripting

Find, regular expression, anyway to simplify this find command?

Hello everyone, first post here, trying to learn scripting on my own and this forum as been really helpful so far. I made few little scripts working great but I m facing some problems with RE. I have a bunch of files in many subdirectories called *001.ext *002.ext OR simple *.ext or *01.ext... (7 Replies)
Discussion started by: Sekullos
7 Replies

5. UNIX for Dummies Questions & Answers

Find files that don't match expression

How Do I find all files in /home that are not .jpgs? (5 Replies)
Discussion started by: glev2005
5 Replies

6. Shell Programming and Scripting

Regular expression to find the length of a field

Hi, in the cobol copy books is there any regular expressions to be used in awk to fetch the length of each columns? below mentioned are the examples. Copy Book Sample 01 tablename. 02 group header. 03 col1 s9(10)V99. 03 Col2 s9(10)V9(3). 03 Col3 XXXX 02... (7 Replies)
Discussion started by: ahmedwaseem2000
7 Replies

7. UNIX for Dummies Questions & Answers

grep regular expression to find = not ==

I suspect this is commonly done, but haven't found the right combination of search terms to find the answer. I want to grep for lines in .cpp files that contain only 1 '=' sign in an if statement. e.g., if (a = b) -- find this if (a==b) -- don't find this My attempt: egrep... (7 Replies)
Discussion started by: offkilter
7 Replies

8. UNIX for Dummies Questions & Answers

using regular expression for directories in find command

Hi, I want to find the files available in a directory /var/user/*/*/data/. I tried using the command "find /var/user/ -path '*/*/data/ -name '*' -type f" it says find: 0652-017 -path is not a valid option and then i tried using "find /var/user/ -name '*/*/data/*' -type f" but its not... (3 Replies)
Discussion started by: vinothbabu12
3 Replies

9. Shell Programming and Scripting

Can't find the mistake in sed expression

Hi there, Can anyone help me find the correct expression for sed. I want to repace iface eth0 inet wathever with iface eth0 inet static Thanks for your help Santiago (5 Replies)
Discussion started by: chebarbudo
5 Replies

10. Shell Programming and Scripting

awk expression to find one or more zeros

Hi, We have a flat file with an account number column . Some of the account numbers are just zeros. e.g., 0, 000, 000000. I am trying to pick out such records which have only zeros in their account number column (column #8). I tried an awk expression : awk '{ FS=" "}{if ( match($8, "0+") )... (3 Replies)
Discussion started by: hnhegde
3 Replies
Login or Register to Ask a Question