in reply to Combine multiple lines into one line

Here is a "complete" perl script that will remove any linefeeds and formfeeds in your parameters.
#!/path/to/your/perl # $1 $2 $3 (shell) are in $ARGV[0], $ARGV[1] and $ARGV[2] (perl) $ARGV[2]=~ s/[\r\n]+/ /g; # Now $3/$ARGV[2] doesn't contain any newline/linefeed anymore $shellindex=1; foreach (@ARGV) { print '$',$shellindex,' ($ARGV[',$shellindex-1,']: ',$_,"\n"; ++$shellindex; }

Replies are listed 'Best First'.
Re: Re: Combine multiple lines into one line
by hyliau (Initiate) on Jun 23, 2003 at 10:52 UTC
    hi Skeeve, Can this be done in Shell script? How? Btw, I would like to test this. If I create a text file which contain multiple lines, how do I pass this file into this script and test the output? One more thing, if the multiple lines contain character like double-quote ("), and I would like to get rid of those wild character, how should I do it? Appreciate your help. Thanks. rgds, hyliau
      hi, Anybody can help me on the last posted issued by me. That is, how to get rid of wild character like double-quote (") in a multiple line? Anywhere to change the Perl script to Shell script as well? Thanks. rgds, hyliau

        Hi hyliau. I realise that english is probably not your first language, but I'm afraid that is it quite difficult to work out what it is that you are trying to do. In your first post you mentioned "HP NNM". There maybe some here that will recognise what that is, and may even have used it, but most of us haven't a clue what it is, which makes it impossible for us to try and help you. Your terminology is also a little confusing, " is not normally refered to as a "wildcard" character.

        If you would post an example of the data that you need to clean up, and the same example as you would like it to become, it would be a lot easier for us to try and help you.

        Also, it is generally a good idea to post your attempt to do what you are doing. This helps us understand your problem, and will help you because you will get feedback indicating what you are doing wrong.


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller