Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^5: One-liner only checking the first line of the input file

by stevieb (Canon)
on Nov 11, 2015 at 15:04 UTC ( #1147464=note: print w/replies, xml ) Need Help??


in reply to Re^4: One-liner only checking the first line of the input file
in thread One-liner only checking the first line of the input file

That's a MacOS line ending \r, aka a carriage return. See if this works:

perl -012 -lane 'print "$F[2]\t$F[7]" if $F[7] > 0' < input.txt

The -0 flag sets the input record separator (line ending) to \r in octal form.

Replies are listed 'Best First'.
Re^6: One-liner only checking the first line of the input file
by TJCooper (Beadle) on Nov 11, 2015 at 15:13 UTC
    Same output as before unfortunately.

      On the command line, make a backup of the file, then type vi input.txt, then inside of vi, type :set ff=unix, hit ENTER, then type :wq. It would be worth noting whether the file appears as you expect before you run the above commands.

      That'll set line endings to \n (at least it should). Then run your original one-liner to see if that worked.

        Fixed! Brilliant, thank you.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1147464]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2021-10-23 13:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (88 votes). Check out past polls.

    Notices?