[Ilugc] Re: sed info

  • From: raja.mallik@xxxxxxxxxxx (Raja Mallik)
  • Date: Wed Feb 16 19:02:43 2005


A few handy tips...i would like to share..and all those who suggested..

# Path declaration
ABS_PATH=`pwd`

#Finding the files with <MATCH_TAGS> text and save it as proper format
in "txt2" file

find . -exec grep -q "RCSID $Id" '{}' \; -print > txt2

#get each line of the file path stored in txt2 file.
NUM_OF_FILE=`sed -n '$=' txt2`

#Start deleting line for MATCH_TAGS on each file and place them back to
their respective location.
for ((i=1; i <= NUM_OF_FILE; i++))
do
     EACH_LINE=`sed -n ${i}p txt2`
     echo $EACH_LINE
     sed -e '/MATCH_TAGS/d' $ABS_PATH$EACH_LINE > $i.c
     mv $i.c $ABS_PATH$EACH_LINE
     echo -n "$i"
done


This looks farily simple with all your help ...It works..

Thanks
Raja


On Wed, 2005-02-16 at 18:43, Asokan Pichai wrote:

Date: Wed, 16 Feb 2005 16:16:11 +0530
From: Noorul Islam <Noorul.Islam@xxxxxxxxxxx>
Subject: Re: [Ilugc] Sed info
To: Raja Mallik <raja.mallik@xxxxxxxxxxx>
Cc: ilugc-bounces@xxxxxxxxxxxxx, chennailug <ilugc@xxxxxxxxxxxxx>
Message-ID:
    <OF6AB1EF7A.848F63F1-ON65256FAA.003B13AD 
-65256FAA.003CBC21@xxxxxxxxxxxxxxxxx>
    
Content-Type: text/plain; charset="US-ASCII"

for ((i=0; i< 100; i++ ))
do
    sed -n '$ip' txt2
done

ilugc-bounces@xxxxxxxxxxxxx wrote on 02/16/2005 04:19:59 PM:

Hi all,

`sed -n '1p' txt2` --it displays on first line of file txt2

How ever if Iwant to use a loop replacing 1 with i as

for ((i=0; i< 100; i++ ))
do
   Each_line=`sed -n '$ip' txt2`
   echo $Each_line
done

here i find it echos p, 1p, 2p..., 99p

but I want the output of each line..

Any pointers ..

-Raja


On a totally different (and possibly irrelevant to OP's needs) track

sed is a poor choice for this

head -100 txt2

will do the same job.


Asokan Pichai
---------------------
If you are a fresher interested in effective career options
take a look at http://www.mafoiacademy.com

_______________________________________________
To unsubscribe, email ilugc-request@xxxxxxxxxxxxx with 
"unsubscribe <password> <address>"
in the subject or body of the message.  
http://www.ae.iitm.ac.in/mailman/listinfo/ilugc

Other related posts: