using perl on the command line, like sed or awk

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • gorda

    using perl on the command line, like sed or awk

    Hello,

    Using sed or awk, I can quickly parse and perform operations on the
    command line itself as in:

    cat file | sed 's/cat/dog'
    cat file | awk ' /cat/ {print "found the cat"} '

    How can i do something like the above in perl on the command line
    without having to write a script in a seperate file?

    Thanks
    -s
  • Eric J. Roode

    #2
    Re: using perl on the command line, like sed or awk

    smith4894@excit e.com (gorda) wrote in
    news:87fbf9fb.0 310201340.6a378 1f@posting.goog le.com:
    [color=blue]
    > Hello,
    >
    > Using sed or awk, I can quickly parse and perform operations on the
    > command line itself as in:
    >
    > cat file | sed 's/cat/dog'
    > cat file | awk ' /cat/ {print "found the cat"} '
    >
    > How can i do something like the above in perl on the command line
    > without having to write a script in a seperate file?[/color]

    perl -pe 's/cat/dog/' file

    See 'perldoc perlrun'

    --
    Eric
    $_ = reverse sort $ /. r , qw p ekca lre uJ reh
    ts p , map $ _. $ " , qw e p h tona e and print

    Comment

    • Andrew Shitov

      #3
      Re: using perl on the command line, like sed or awk

      > How can i do something like the above in perl on the command line[color=blue]
      > without having to write a script in a seperate file?[/color]


      $ perl -e 'print 123;'

      Comment

      Working...