The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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 and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shell script to format a .CSV data Uday1982 Shell Programming and Scripting 8 02-04-2008 05:28 AM
how to number format a data file without using SED? Cactus Jack UNIX for Dummies Questions & Answers 3 01-12-2008 07:47 PM
Add data in days:hours:min:sec format krishna_sicsr Shell Programming and Scripting 1 03-17-2007 11:39 AM
data format from (4.56 0.7) -> 4.6(7) awk?! ahan Shell Programming and Scripting 4 05-07-2006 08:53 PM
kstat - format of output data? ozvena UNIX for Dummies Questions & Answers 4 06-16-2005 04:35 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 09-23-2003
inquirer's Avatar
inquirer inquirer is offline
Registered User
  
 

Join Date: Aug 2001
Posts: 79
Question format data

i have this data:

Code:
GREEN LIST :
12321     34534
GREEN LIST :
45645 --- 23423
WHITE LIST :
23479     34534     75483     76924
12345 --- 12351     56778 --- 23330
GREEN LIST :
23567
the output must be:

Code:
GREEN LIST : 12321
GREEN LIST : 34534
GREEN LIST : 45645 --- 23423
WHITE LIST : 23479
WHITE LIST : 34534
WHITE LIST : 75483
WHITE LIST : 76924
WHITE LIST : 12345 --- 12351 
WHITE LIST : 56778 --- 23330
GREEN LIST : 23567
can you see what i mean? partially, i tried doing:

Code:
awk '
BEGIN { FS = "     " }
/LIST/ { tag = $1 ; next }
/[0-9]/ { print tag, $1 }' < filename
and it prints only the $1 but when i tried:

Code:
/[0-9]/ { print tag ; print $1 }' < filename
it works but the output is not what i wanted. :P

how can we do this

pls help
  #2 (permalink)  
Old 09-24-2003
davidg's Avatar
davidg davidg is offline
Registered User
  
 

Join Date: Jul 2003
Location: Holland
Posts: 207
Your solution might be to first remove the new line after "LIST :". I think you know better how to do it than me. At least a newline is \n you should subsitute it with nothing.
Good luck.

Regs David
  #3 (permalink)  
Old 09-24-2003
inquirer's Avatar
inquirer inquirer is offline
Registered User
  
 

Join Date: Aug 2001
Posts: 79
already have the solution

i just used the following:

Code:

grep -E "LIST|^  [0-9]" ${1}  | sed 's/ --- /---/g' | sed 's/     / /g' |
awk '
/LIST/ { tag = $1 ; next }
/[0-9]/ { print tag , $0 }' > filter_out.log

cut -f1 -d" " filter_out.log > type_list.log

cut -f2 -d" " filter_out.log > field_one.log
cut -f3 -d" " filter_out.log > field_two.log
cut -f4 -d" " filter_out.log > field_three.log
cut -f5 -d" " filter_out.log > field_four.log

paste -d" " type_list.log field_one.log | grep "[0-9]" > out.txt
paste -d" " type_list.log field_two.log | grep "[0-9]"  >> out.txt 
paste -d" " type_list.log field_three.log | grep "[0-9]"  >> out.txt
paste -d" " type_list.log field_four.log | grep "[0-9]"  >> out.txt
although the output is something like:

Code:

GREEN 12321

instead of 

GREEN LIST : 12321
it works fine with me.

thanks anyway for the reply :P
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 06:34 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0