File processing

Roman Suzi rnd at onego.ru
Tue Jul 10 04:47:40 EDT 2001


On 10 Jul 2001, Harald Kirsch wrote:

>"Chris McMillan" <christopherjmcmillan at eaton.com> writes:
>
>> Hello all!
>>
>> I'm trying to write a script that will open a file, delete the first line,
>> and then save the file with the same name.  Can someone please point me in
>> the right direction?  Thanks!
>
>
>Umpf. I really like python, but sometimes other solutions are less
>cumbersome. With bash it's a one-liner like:
>
>  for x in *; do y=`basename $x`.new; tail +1 $x >$y; mv $y $x; done

Or even "simpler" using ed:

   for x in *; echo -e "1,1d\nw" | ed $x; done

>Sorry, couldn't read from your message if you are on Microsoft where
>a bash script usually does not help a lot.

Sincerely yours, Roman Suzi
-- 
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Tuesday, July 10, 2001 _/ Powered by Linux RedHat 6.2 _/
_/ "<CTRL>-<ALT>-<DEL> is the key to success" _/





More information about the Python-list mailing list