Cat file a to *.xls files

Discussion in 'Perl Misc' started by Jim, Apr 26, 2007.

  1. Jim

    Jim Guest

    Hi I'm trying to get a perl script to work without much luck.

    What I'm trying to do is to:

    cat filea.txt to all .xls files in a directory

    your help would be appreciated

    Thanks in advance
    Jim, Apr 26, 2007
    #1
    1. Advertising

  2. Jim

    Mirco Wahab Guest

    Jim wrote:
    > Hi I'm trying to get a perl script to work without much luck.
    > What I'm trying to do is to:
    > cat filea.txt to all .xls files in a directory


    Are you Jim the Italian living in French
    Canada trying to write English?

    (I didn't understand anything)

    What's meant by 'cat' here? Can you explain?

    Regards

    M.
    Mirco Wahab, Apr 26, 2007
    #2
    1. Advertising

  3. Jim <> wrote:
    > Hi I'm trying to get a perl script to work without much luck.
    >
    > What I'm trying to do is to:
    >
    > cat filea.txt to all .xls files in a directory
    >
    > your help would be appreciated



    No Perl needed, just use the shell!


    # untested
    for file in *.xls; do
    cat filea.txt >>$file
    done


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 26, 2007
    #3
  4. Jim

    tuser Guest

    On Apr 27, 12:54 am, Tad McClellan <> wrote:
    > Jim <> wrote:
    > > Hi I'm trying to get a perl script to work without much luck.

    >
    > > What I'm trying to do is to:

    >
    > > cat filea.txt to all .xls files in a directory

    >
    > > your help would be appreciated

    >
    > No Perl needed, just use the shell!
    >
    > # untested
    > for file in *.xls; do
    > cat filea.txt >>$file
    > done


    in Perl (untested):
    system("cat filea.txt >>$_") for glob "*.xls";
    tuser, Apr 26, 2007
    #4
  5. Jim

    Jim Guest

    On Apr 26, 6:54 pm, Tad McClellan <> wrote:
    > Jim <> wrote:
    > > Hi I'm trying to get a perl script to work without much luck.

    >
    > > What I'm trying to do is to:

    >
    > > cat filea.txt to all .xls files in a directory

    >
    > > your help would be appreciated

    >
    > No Perl needed, just use the shell!
    >
    > # untested
    > for file in *.xls; do
    > cat filea.txt >>$file
    > done
    >
    > --
    > Tad McClellan SGML consulting
    > Perl programming
    > Fort Worth, Texas


    Thanks Tad, it worked nicely but, what I need is to have the contents
    of filea.txt at the start of the .xls files. Is this possible to do?
    Jim, Apr 27, 2007
    #5
  6. Jim wrote:
    > what I need is to have the contents
    > of filea.txt at the start of the .xls files.


    Just for clarification: you want to prepend the content of filea.txt to
    every *.xls file in a given directory.
    Is this correct?

    Your original question was anything but clear.

    jue
    Jürgen Exner, Apr 27, 2007
    #6
  7. Jim <> wrote:
    > On Apr 26, 6:54 pm, Tad McClellan <> wrote:
    >> Jim <> wrote:
    >> > Hi I'm trying to get a perl script to work without much luck.

    >>
    >> > What I'm trying to do is to:

    >>
    >> > cat filea.txt to all .xls files in a directory

    >>
    >> > your help would be appreciated

    >>
    >> No Perl needed, just use the shell!
    >>
    >> # untested
    >> for file in *.xls; do
    >> cat filea.txt >>$file
    >> done
    >>
    >> --
    >> Tad McClellan SGML consulting
    >> Perl programming
    >> Fort Worth, Texas



    It is bad netiquette to quote signatures.


    > Thanks Tad, it worked nicely but, what I need is to have the contents
    > of filea.txt at the start of the .xls files. Is this possible to do?



    # untested
    for file in *.xls; do
    cat filea.txt $file >tmp
    mv tmp $file
    done


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 28, 2007
    #7
  8. On 4/26/2007 5:54 PM, Tad McClellan wrote:
    > Jim <> wrote:
    >>
    >> What I'm trying to do is to:
    >>
    >> cat filea.txt to all .xls files in a directory

    >
    > No Perl needed, just use the shell!
    >
    > # untested
    > for file in *.xls; do
    > cat filea.txt >>$file


    I think Tad has been hanging around Abigail too much lately.

    -mjc
    Michael Carman, Apr 28, 2007
    #8
  9. Michael Carman <> wrote:
    > On 4/26/2007 5:54 PM, Tad McClellan wrote:
    >> Jim <> wrote:
    >>>
    >>> What I'm trying to do is to:
    >>>
    >>> cat filea.txt to all .xls files in a directory

    >>
    >> No Perl needed, just use the shell!
    >>
    >> # untested
    >> for file in *.xls; do
    >> cat filea.txt >>$file

    >
    > I think Tad has been hanging around Abigail too much lately.



    But when _I_ type of bunch of line noise, it never ends up
    being a Perl program. :-(


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Apr 28, 2007
    #9
  10. Jim

    Jim Guest

    On Apr 28, 12:57 am, Tad McClellan <> wrote:
    > Michael Carman <> wrote:
    > > On 4/26/2007 5:54 PM, Tad McClellan wrote:
    > >> Jim <> wrote:

    >
    > >>> What I'm trying to do is to:

    >
    > >>> cat filea.txt to all .xls files in a directory

    >
    > >> No Perl needed, just use the shell!

    >
    > >> # untested
    > >> for file in *.xls; do
    > >> cat filea.txt >>$file

    >
    > > I think Tad has been hanging around Abigail too much lately.

    >
    > But when _I_ type of bunch of line noise, it never ends up
    > being a Perl program. :-(
    >
    > --
    > Tad McClellan SGML consulting
    > Perl programming
    > Fort Worth, Texas


    Thanks for your help. Works perfect!
    Jim, May 2, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Yadagiri Rao KP
    Replies:
    3
    Views:
    388
    Joseph Millar
    Aug 9, 2003
  2. Spendius
    Replies:
    2
    Views:
    2,936
    Rogan Dawes
    Dec 13, 2004
  3. Rymfax
    Replies:
    1
    Views:
    479
    Victor Bazarov
    Apr 13, 2007
  4. zw
    Replies:
    0
    Views:
    347
  5. Saqib Ali
    Replies:
    9
    Views:
    486
    Michael Torrie
    Jan 16, 2012
Loading...

Share This Page