Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: perl one-liner

by mojobo (Initiate)
on Jun 22, 2005 at 21:22 UTC ( [id://469191]=note: print w/replies, xml ) Need Help??


in reply to Re: perl one-liner
in thread perl one-liner

hi guys,
actually shell redirection is what i have been doing in the past (without perl), but i wanted to have a one-liner that can be called externally. The basic idea is to automate editing a file with different access permissions than the user, via sudo, and not have to chown the file first to the user..
i can already edit a file if there is content in the file, without using shell redirection, using a perl one-liner like this:
perl -i -ne 'print unless 1 .. 100; print q{testing} if$.==1' somefile

of course this doesn't truncate the file, which is what i was interested in attempting..

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (7)
As of 2024-04-23 11:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found