Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: add text to each line of a file

by b10m (Vicar)
on Mar 10, 2005 at 19:36 UTC ( #438399=note: print w/replies, xml ) Need Help??


in reply to add text to each line of a file

Why use Perl at all?

ypcat passwd | awk -F: '{ print $1."@domain.local" }' > oneliner.out
--
b10m

All code is usually tested, but rarely trusted.

Replies are listed 'Best First'.
Re^2: add text to each line of a file
by ambrus (Abbot) on Mar 10, 2005 at 22:04 UTC

    Why use awk at all?

    ypcat passwd | perl -wne '/:/ and print "$`\@domain.local\n";'
    or
    ypcat passwd | cut -d: -f1 | sed 's/$/@mydomain.local/'
    or
    ypcat passwd | sed 's/:.*/@domain.local/'
      No! Not the dreaded $` I have trained myself so well to not use them that it now scares me to see it.

      $will->code for @food or $$;

      And to complete the sed:
      ypcat passwd |sed 's/:.*/@domain.local/'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2023-09-21 23:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?