Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-17-2008, 07:40 AM   #1
Registered: Dec 2007
Posts: 73

Rep: Reputation: 15
Unhappy how to format a text file to automate testing procedure

Hi all,

I just want to know that how we can format a text file one like below to get a desired result:

Example text file:

---------- Sine wave test ----------
***OK*** sin-20Hz-0db-5_1ch(ch=0): SNRseg: 100.32 (dB)
***OK*** sin-20Hz-0db-5_1ch(ch=1): SNRseg: 100.32 (dB)
***OK*** sin-20Hz-0db-5_1ch(ch=2): SNRseg: 69.70 (dB)
***OK*** sin-20Hz-0db-5_1ch(ch=4): SNRseg: 99.52 (dB)
***OK*** sin-20Hz-0db-5_1ch(ch=5): SNRseg: 99.52 (dB)

***OK*** sin-20Hz-3db-5_1ch(ch=0): SNRseg: 98.09 (dB)
***OK*** sin-20Hz-3db-5_1ch(ch=1): SNRseg: 98.09 (dB)
***OK*** sin-20Hz-3db-5_1ch(ch=2): SNRseg: 69.71 (dB)
***OK*** sin-20Hz-3db-5_1ch(ch=4): SNRseg: 97.96 (dB)
***OK*** sin-20Hz-3db-5_1ch(ch=5): SNRseg: 97.96 (dB)

***OK*** sin-20Hz-60db-5_1ch(ch=0): SNRseg: 31.50 (dB)
***OK*** sin-20Hz-60db-5_1ch(ch=1): SNRseg: 31.50 (dB)
***OK*** sin-20Hz-60db-5_1ch(ch=2): SNRseg: 31.50 (dB)
***OK*** sin-20Hz-60db-5_1ch(ch=4): SNRseg: 31.50 (dB)
***OK*** sin-20Hz-60db-5_1ch(ch=5): SNRseg: 31.50 (dB)

---------- Sweep frequency sine wave test ----------
***OK*** sweep-20-20kHz-3db-5_1ch(ch=0): min[57]:51.04 (dB)
***OK*** sweep-20-20kHz-3db-5_1ch(ch=1): min[57]:51.04 (dB)
***OK*** sweep-20-20kHz-3db-5_1ch(ch=2): min[26]:33.95 (dB)
***OK*** sweep-20-20kHz-3db-5_1ch(ch=4): min[57]:51.04 (dB)
***OK*** sweep-20-20kHz-3db-5_1ch(ch=5): min[57]:51.04 (dB)

---------- Single channel sine wave test ----------
***OK*** sin-20Hz-0db-FL-5_1ch: SNRseg: 97.22 (dB): soundless-ch: 0
***OK*** sin-20Hz-0db-FR-5_1ch: SNRseg: 95.69 (dB): soundless-ch: 0
***OK*** sin-20Hz-0db-FC-5_1ch: SNRseg: 69.70 (dB): soundless-ch: 0
***OK*** sin-20Hz-0db-BL-5_1ch: SNRseg: 97.22 (dB): soundless-ch: 0
***OK*** sin-20Hz-0db-BR-5_1ch: SNRseg: 95.69 (dB): soundless-ch: 0
***OK*** sin-1kHz-0db-FL-5_1ch: SNRseg: 128.35 (dB): soundless-ch: 0
***OK*** sin-1kHz-0db-FR-5_1ch: SNRseg: 104.62 (dB): soundless-ch: 0
***OK*** sin-1kHz-0db-FC-5_1ch: SNRseg: 78.85 (dB): soundless-ch: 0
***OK*** sin-1kHz-0db-BL-5_1ch: SNRseg: 128.35 (dB): soundless-ch: 0

---------- lfe channel sine wave test ----------
***OK*** sin-20Hz-0db-LF-5_1ch: SNRseg: 33.01 (dB): soundless-ch: 0
***OK*** sin-20Hz-3db-LF-5_1ch: SNRseg: 33.25 (dB): soundless-ch: 0
***OK*** sin-20Hz-60db-LF-5_1ch: SNRseg: 30.62 (dB): soundless-ch: 0


I want a result like this:

Sine wave test
sin-20Hz-0db-5_1ch 69.70
sin-20Hz-3db-5_1ch 69.71
sin-20Hz-60db-5_1ch 31.50

Sweep frequency sine wave test
sweep-5_1ch 33.95
Single channel sine wave test
sin-20Hz-0db-FL-5_1ch 97.22
sin-20Hz-0db-FR-5_1ch 95.69
sin-20Hz-0db-FC-5_1ch 69.70
sin-20Hz-0db-BL-5_1ch 97.22
sin-20Hz-0db-BR-5_1ch 95.69
sin-1kHz-0db-FL-5_1ch 128.35

lfe channel sine wave test
sin-20Hz-0db-LF-5_1ch 33.01
sin-20Hz-3db-LF-5_1ch 33.25
sin-20Hz-60db-LF-5_1ch 30.62
Old 03-17-2008, 08:39 AM   #2
Registered: May 2001
Posts: 29,359
Blog Entries: 55

Rep: Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546Reputation: 3546
cat file | while read line; do
 case "${line:0:1}" in
  -) echo "${line//-/}";;
  *) i=(${line}); "${i[1]%%(*} ${i[3]//*:}";;
or something like that.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
"Have to automate the SSH login procedure through shell scripting" sorav Programming 2 11-21-2007 04:53 AM
Automate command line testing of program in Linux jigneshs Programming 3 06-09-2007 01:43 PM
Procedure to automate the browser pratap.iisc Linux - General 3 04-19-2007 03:28 AM
LXer: Automate GUI testing with TestNG-Abbot LXer Syndicated Linux News 0 03-01-2007 10:01 PM
LXer: Speaking Unix, Part 6: Automate, automate, automate! LXer Syndicated Linux News 0 01-04-2007 09:54 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:47 AM.

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