Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 680
  • Last Modified:

Append a string to a file in Perl in one-line fashion

Want to append a string to a file in Perl one-line fashion. DOS Shell, we can do
echo This is a test >> test.txt
In Perl, can it be achived? I know that open a file with option ">>..." in Perl. Appending can be done. How about commad-line fashion?  
0
jl66
Asked:
jl66
3 Solutions
 
jl66Author Commented:
The command-line fshion means that
perl -p -e ..........
0
 
Adam314Commented:
perl -e 'print "The new line\n"' >> file.txt
0
 
jl66Author Commented:
Thanks for the info. I tried it and found the following:
E:\oracle\perl\5.8.3\bin\MSWin32-x86-multi-thread>perl -e 'print "The new line\n" ' >> file.txt
Can't find string terminator "'" anywhere before EOF at -e line 1.

E:\ora10g\perl\5.8.3\bin\MSWin32-x86-multi-thread>perl -version
This is perl, v5.8.3 built for MSWin32-x86-multi-thread
Copyright 1987-2003, Larry Wall
....
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
jl66Author Commented:
ora10g = oracle.
0
 
ozoCommented:
perl -le "print 'The new line' " >> file.txt
0
 
TalmashCommented:
why not trying simple way:

echo "new line" >> file
0

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now