develooper Front page | perl.beginners | Postings from February 2002

Re: help for sed

Thread Previous | Thread Next
From:
John W. Krahn
Date:
February 6, 2002 15:38
Subject:
Re: help for sed
Message ID:
3C61BE52.8F930F71@acm.org
R p wrote:
> 
> hi everyone.

Hello,

> i am trying to use sed in order to change all my batch
> script.

Sorry, I'll have to show you a Perl solution.  :-)

> the pb is:
> 
> i have the following batch:
> @echo on
> TIMETHIS.exe k:\Validation\Soft\abc.exe
> k:\test_1.sct k:\Validation\PlugIn\abc.link >>
> k:\test_1.log
> @echo off
> exit
> ------------------------------------
> i want to delete all character after abc.link

ALL characters or just all characters on the same line?


> how can i do with the command sed.
> i have written this. but it does not work
> --------------------------------------
> chem=K:/Validation/try
> cd $chem
> 
> echo "Creation Of All '*.bat files ..."
> find -type f -iname '*.bat' > list.txt
> 
> for i in `cat list.txt`
> do
>   echo "Processing File $i .."
>   if [ -f $i.new ]; then rm -f $i.new ;fi;
>   sed  -e ' s/^>>//g' $i > temp
>   mv temp $i
> done
> echo "Done."


#!/usr/bin/perl -w
use strict;
use File::Find;

local $^I = '';
local $/;
local @ARGV;

find( sub { -f and /\.bat$/i and push @ARGV, $File::Find::name }, '.' );

while ( <> ) {
    # remove everything after "abc.link" on the first line found
    s/abc\.link.*$/abc.link/m;
#   # remove everything after "abc.link" on all lines
#   s/abc\.link.*$/abc.link/mg;
#   # remove everything after "abc.link" to the end of the file
#   s/abc\.link.*/abc.link\n/s;
    }

__END__


John
-- 
use Perl;
program
fulfillment

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About