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 > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
File Transfer that is not so trivial I guess Legend986 UNIX for Dummies Questions & Answers 1 03-07-2008 05:40 AM
simple script help ali560045 Shell Programming and Scripting 4 01-24-2008 05:24 AM
guess the fault :) maskot Shell Programming and Scripting 4 05-24-2007 05:21 AM
Simple Script Help Skunkie UNIX for Dummies Questions & Answers 4 10-02-2006 11:18 AM
need help with simple awk/ksh script tefflox Shell Programming and Scripting 18 09-28-2006 01:55 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2003
HowardIsHigh HowardIsHigh is offline
Registered User
  
 

Join Date: Jun 2003
Posts: 11
Need help for a simple script (i guess so...)

Hi all!

here is a sample of the file i am working on :


$ cat toto.txt
$20030613150250:Flux:ASS_IARD
20030613150250:Nombre d enregistrements Ecrits :27
20030613150250:Flux:ASS_TIER
20030613150250:Nombre d enregistrements Ecrits :27
20030613150251:Flux:ASS_PERS
20030613150251:Nombre d enregistrements Ecrits :52
20030613150251:Flux:LIEN_CONT
20030613150251:Nombre d enregistrements Ecrits :27
20030613150252:Flux:LIEN_EA
20030613150252:Nombre d enregistrements Ecrits :52
20030613150252:Flux:ASS_MODU
20030613150252:Nombre d enregistrements Ecrits :180


i want to obtain the following result :

ASS_IARD:27
ASS_TIER:27
ASS_PERS:52
LIEN_CONT:27
LIEN_EA:52
ASS_MODU:180

I already wrote something.... :

if [ -f toto.txt ]
then
while read LINE
do
if [ `echo ${LINE} | grep Flux` ]
then
echo $LINE | awk -F ":" '{print $3}' >> ./LOG.wri
fi
done < toto.txt
fi

i know i feel pity for this one.......

PLEASE HELP

Regards

Howard
  #2 (permalink)  
Old 07-01-2003
oombera's Avatar
oombera oombera is offline Forum Advisor  
Registered User
  
 

Join Date: Aug 2002
Location: Cleveland, OH
Posts: 804
Well, you had a good start.. there may be a shorter way to do this, but here's one way:
Code:
flag=0

if [ -f yourFile ]; then
 awk -F":" '{print $3}' yourFile |
 while read LINE
 do
  if [ $flag -eq 0 ]; then
   echo -n $LINE: >> resultFile
   flag=1
  else
   echo $LINE >> resultFile
   flag=0
  fi
 done
fi
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 12:47 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