Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > simple perl script

Reply
Thread Tools

simple perl script

 
 
Jerry Maguire
Guest
Posts: n/a
 
      08-17-2003
Hi,
I would like to write a perl script to open and file and add a prefix to all
the lines of that file.
The file will be like:

name1blah
name2blah
name3blah

I have created the following script:
#!/bin/sh
cat test |
while read name
do
printf 'new'$name>>newfile.txt;
done

Now the problem is it is adding all the lines in one line.
The output is:
newname1blahnewname2blahnewname3blah

jerry



 
Reply With Quote
 
 
 
 
Chesucat
Guest
Posts: n/a
 
      08-18-2003
On 18 Aug 2003, Sam Holden wrote:

> Except of course that echo adds a newline by default. And echo \n will
> output "n"... - since \n will be converted to n by most shells, if you
> have a strange shell that doesnt do that then it'll output "\n"
>
> > In the future, you might want to post in comp.unix.shell!

>
> A good idea.


Yeah, I forgot about! But, anyway, it worked ksh! I figured he might
have to tweak it some for his shell. I should had use '-n' option for the
echo command, or I just should left the 'printf' statement in but I
couldn't get it to work for me! 'printf' has a lot more options than
'echo', so I thought I would keep it simple with 'echo'. Thank you for
pointing that out!

chesucat

--
http://www.velocityreviews.com/forums/(E-Mail Removed)
SDF Public Access UNIX System - http://sdf.lonestar.org
Interpreter, n.:
One who enables two persons of different languages to
understand each other by repeating to each what it would have been to
the interpreter's advantage for the other to have said.
-- Ambrose Bierce, "The Devil's Dictionary"

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to call a simple perl script from HTML without need of HTTPS but simple HTTP ? Wladimir Borsov Perl Misc 4 05-11-2006 09:29 AM
Execute another perl script from my perl script Petterson Mikael Perl Misc 3 01-05-2005 01:31 PM
problem calling perl script from SOAP server perl script pj Perl Misc 3 04-09-2004 10:23 PM
Perl Help - Windows Perl script accessing a Unix perl Script dpackwood Perl 3 09-30-2003 02:56 AM
How to make Perl Script "POST" call from another Perl Script??? Wet Basement Perl 1 07-15-2003 10:25 PM



Advertisments