in reply to Re: very basic, just beginning
in thread very basic, just beginning
This code might get you in trouble if there are newlines in the file. If that is the case then...
It puts "filename.txt" as every other line in the file. The while loop is what gets you in trouble here. Perhaps if you do a undef $/ somewhere in there.
Or, even better, start with your version and test for the first line.
This adds three things - it removes the .txt from the filename first. Second, it adds the initial '>' character. Finally, it only rewrites the first line. ($. is line number).perl -pi -e '$ARGV =~ s/\.txt//; $_=">$ARGV\n$_\n if($.==1)"' *.txt
Not the most elegant, but it works.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: very basic, just beginning
by fletcher_the_dog (Friar) on Aug 27, 2003 at 18:25 UTC | |
by jmanning2k (Pilgrim) on Aug 27, 2003 at 18:35 UTC |