I want to print the first 10 lines of a huge file into a new file. With this oneliner I can print the lines on the monitor:
> perl -ne "print if $. < 10" in.csv
I tried this:
> perl -ne "print if $. < 10" in.csv >out.txt
But this does only create the file out.txt without writing the first lines into it. What is wrong with this code?
Thanks for help
Windows 7 / Strawberry Perl
Update1:
If I send the print result on monitor using:
> perl -ne "print if $. <= 10" in.csv
the program does not stop, that is, the first ten lines are output on the monitor but it does not end with:
>
I have to stop the program using Ctrl+c.
Using the simple csv-File like ikegami (just some rows) the onliner works. I assume there is something within the csv-file.
Update 2:
The original onliner:
> perl -ne "print if $. <= 10" in.csv >out.txt
works. I have to wait some seconds. The csv-file is 2 GB large. The onliner:
> perl -pe "exit if $. > 10" in.csv >out.txt
gives the result immediately. Conclusion: the first onliner goes through all rows, the second exit after 10 rows.
Sorry that I bother you with this problem. I learnt my lesson: use an appropriate onliner or wait some more seconds.