The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help needed for Shell Script..... pulkit Shell Programming and Scripting 0 02-22-2008 04:25 AM
SHell Scripting Help Needed cskumar Shell Programming and Scripting 2 07-16-2006 10:55 PM
Help needed - shell scripting garric Shell Programming and Scripting 8 05-23-2006 03:08 AM
Korn Shell Help Needed stevefox Shell Programming and Scripting 5 12-05-2005 07:17 PM
Shell help needed stevefox Shell Programming and Scripting 11 11-27-2005 09:49 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-01-2006
Registered User
 

Join Date: Aug 2005
Posts: 111
Question K Shell Help needed

Could someone tell me the code for doing the below inside a k shell?

I have a file file below:


Code:
$ more file1
>>>>>
AAA
BBB
CCC
<<<<<
>>>>>
DDD
EEE
FFF
<<<<<
I want the lines between ">>>>>" and "<<<<<" to be one line like below:

AAA BBB CCC
DDD EEE FFF

Any help will be greatly appreciated.
Reply With Quote
Forum Sponsor
  #2  
Old 02-01-2006
vino's Avatar
Supporter (in vino veritas)
 

Join Date: Feb 2005
Location: Bangalore, India
Posts: 2,698
Code:
#! /bin/ksh

while read line
do

        if [[ "$line" == *">>"* ]] ; then
        TXT=""
        elif [[ "$line" == *"<<"* ]] ; then
        echo "$TXT"
        else
        TXT="$TXT$line "
        fi ;

done < file1
Reply With Quote
  #3  
Old 02-01-2006
Registered User
 

Join Date: Aug 2005
Posts: 111
Talking

That's great!
I appreciate your quick and accurate reply everytime!
Thanks alot vino!
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 10:31 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0