LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-09-2016, 03:02 AM   #1
rahulevince
LQ Newbie
 
Registered: Jul 2016
Posts: 1

Rep: Reputation: Disabled
Linux shell script for regular expression in expect command


I need to match string and new line in regular expression or something like split in expect command. Here is the example - command output - Notification value: 34 39 48 Notification value: 44 02 09 Notification value: 54 03 28

I need to extract the output that match after "value: " i.e only hexa-value and up to every lines until second byte in last line must be 03 and also extract first bit i.e 5 from 54

But if 03 is in second line than it should not consider that 03. It must match at the end of line in every output.

One more thing, the lines of output is not fixed, it can be 3 or 4 or 5 or more than that. That's why we need to match in the last line and second byte i.e 03.

Thanks in advance
 
Old 07-09-2016, 09:37 AM   #2
HMW
Member
 
Registered: Aug 2013
Location: Sweden
Distribution: Debian, Arch, Red Hat, CentOS
Posts: 773
Blog Entries: 3

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
Quote:
Originally Posted by rahulevince View Post
I need to match string and new line in regular expression or something like split in expect command. Here is the example - command output - Notification value: 34 39 48 Notification value: 44 02 09 Notification value: 54 03 28

I need to extract the output that match after "value: " i.e only hexa-value and up to every lines until second byte in last line must be 03 and also extract first bit i.e 5 from 54

But if 03 is in second line than it should not consider that 03. It must match at the end of line in every output.

One more thing, the lines of output is not fixed, it can be 3 or 4 or 5 or more than that. That's why we need to match in the last line and second byte i.e 03.

Thanks in advance
Hello and welcome!

Please post the EXACT infile (in code tags), and post EXACTLY what you want to achieve (in code tags) from that infile.
Then please show us what you have tried this far, and why and where it fails.

With best regards,
HMW
 
Old 07-09-2016, 11:01 AM   #3
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191Reputation: 3191
To me that was as clear as mud ... sorry, but the entire description seems very unclear. You also have not shown any sign of attempting a solution yourself??
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Regular expression in expect script to prevent printing to screen legendmac Linux - Newbie 0 05-30-2015 12:45 AM
[SOLVED] Is there a command that can match a string with regular expression in linux ? 915086731 Linux - General 13 08-22-2011 02:45 AM
tcl expect - problem with regular expression in interact mode chekhov_neo Programming 3 12-09-2010 02:55 PM
Using regular expression in expect script nik1984 Programming 1 08-28-2008 06:25 AM
exec the expect command in a shell script wanghao Linux - Networking 6 11-23-2007 11:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration