Loading ...
Sorry, an error occurred while loading the content.

Re: [atlantisdev] Unix Shell / Perl Questions

Expand Messages
  • Anthony Briggs
    ... You don t - UNIX shells are simple creatures, and what s happening when you give wildcards is that the shell just expands everything. So your command ends
    Message 1 of 4 , Oct 31, 2003
    • 0 Attachment
      At 10:58 PM +0000 31/10/03, pjtr wrote:
      >Heya.
      >
      >I have two questions.
      >
      >A) How can I execute the command 'move name1.* name2.*' in a unix
      >shell?

      You don't - UNIX shells are simple creatures, and what's happening
      when you give wildcards is that the shell just expands everything. So
      your command ends up looking like:

      move name1.a name1.b name2.a name2.b

      which tries to move everything into name2.b. Annoying, isn't it? The
      way to do what you want is much trickier, but starts out as something
      like this:

      for i in `ls name1.*`; do echo $i; done

      actually breaking down the name into sections seems pretty tough, and
      not the sort of thing that you'd be wanting to do in a shell. This is
      why a lot of UNIX admins use more powerful tools like Perl or Python
      to do 'heavy lifting'.

      This trick gets a lot of new UNIX people eventually, so don't feel bad.

      >B) How can make perl to output a text file, not just a string with
      >the print "string" command.

      It's been a while since I've done Perl, but I managed to find this
      tutorial online:

      <http://www.perldoc.com/perl5.8.0/pod/perlintro.html>

      which has a quick intro to files about 3/4 of the way down.

      <http://www.perl.org> seems to be a good place to start to find
      things, and there's always google.

      Ant
      --
      ----------------------------------------------------
      HyPEraCtiVE? HeY, WhO aRE YoU cALliNg HypERaCtIve?!
      aBRiGgS@...
      ----------------------------------------------------
    • pjtr
      Thanks! I think I dealt with those problems :)
      Message 2 of 4 , Nov 1, 2003
      • 0 Attachment
        Thanks!

        I think I dealt with those problems :)
      • Will Walker
        ... This one was answered (use your shell s for construct). ... open(MYFILE, myfilename ) || die could not write myfilename: $! n ; print MYFILE whatever
        Message 3 of 4 , Nov 3, 2003
        • 0 Attachment
          On Fri, Oct 31, 2003 at 10:58:16PM -0000, pjtr wrote:
          > Heya.
          >
          > I have two questions.
          >
          > A) How can I execute the command 'move name1.* name2.*' in a unix
          > shell?

          This one was answered (use your shell's 'for' construct).


          > B) How can make perl to output a text file, not just a string with
          > the print "string" command.


          open(MYFILE,">myfilename") || die "could not write myfilename: $!\n";

          print MYFILE "whatever you want to print\n";

          close(MYFILE);
        Your message has been successfully submitted and would be delivered to recipients shortly.