The equivalent one-liner for Aman's suggestion is: perl -p -i -e's/(?:!|SUB-TOTAL)//' yourfile.txt
The above will seek out ! or SUB-TOTAL, replace them and write the results to the current file i.e overwirte the file. If you want to back up the current file, use the one-liner as follows: perl -p -i '.bak' -e 's/(?:!|SUB-TOTAL)//' yourfile.txt. The back up will be to the file yourfile.txt.bak. You will sometimes see the -p -i switches shown as -pi which has the same effect. I use these oneliners a lot to make quick changes on the fly. Alfred Vahau IT Services Uni. PNG ------------------------------------------- Hi Thomas File editing is particularly easy in perl. Herez some sample code to get you started : ---------------------------------------------------------------------------- ------------------------------ @ARGV='C:\Documents and Settings\athind\Desktop\test\File2Edit.txt'; # path to the file you want to edit $^I=".bak"; # this will be appended to the original filename and will act as BackUp. while (<>) { s/!//; # will replace ! with nothing i.e. all instances of ! will be removed. s/SUB-TOTAL://; # same as above for SUB-TOTAL: print; # writes the new file line by line } ---------------------------------------------------------------------------- -------------------------------- Try this on the file you want to edit. Anything else you want to edit\replace can be done by the s/what2replace/bywhat2replace/; -aman -----Original Message----- From: Thomas Browner [mailto:thomas.browner@;digidyne.com] Sent: Wednesday, November 13, 2002 7:33 PM To: [EMAIL PROTECTED] Subject: file editting I there away to edit a file in perl? This is what is I am trying to do. I have a file that I want to remove some content. This is an example of a line: ! 6134.21 3200 SUB-TOTAL: M:\alvin I want to remove the ! and SUB-TOTAL. I hope some one can tell me an simple way of doing this sine I am a new to perl. Thank you, Thomas