2 Replies - 1229 Views - Last Post: 23 November 2011 - 08:34 AM

#1 CapC  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 30
  • Joined: 27-September 11

Perl to generate bash sequence

Posted 22 November 2011 - 03:10 PM

Essentially I have 15 statements that have to be entered in a specific sequence.

12 cat statements
mkdir
mv
split


I want to package these 15 statements into a perl script to ease off the repetitiveness. What I for whatever reason can't seem to find is what I need to prefix UNIX bash commands with?

do I use something like a series of
run("cat xxxx_??.txt > xx_xx.txt");
run("split -l 1000000 blah_blah.txt blah_blah_");

or how do I prefix it?

This post has been edited by CapC: 22 November 2011 - 03:10 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Perl to generate bash sequence

#2 sepp2k  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2132
  • View blog
  • Posts: 3,263
  • Joined: 21-June 11

Re: Perl to generate bash sequence

Posted 22 November 2011 - 04:14 PM

You can put them in backticks (`command`) or qx/command/ to execute them.

Note though that shell scripts support for-loops too, so there's no reason to use perl for something as simple as this (unless you already know perl well and don't want to learn how to do for-loops in bash).

This post has been edited by sepp2k: 05 December 2011 - 07:47 AM

Was This Post Helpful? 2
  • +
  • -

#3 CapC  Icon User is offline

  • New D.I.C Head

Reputation: 3
  • View blog
  • Posts: 30
  • Joined: 27-September 11

Re: Perl to generate bash sequence

Posted 23 November 2011 - 08:34 AM

Thanks sepp2k.

I'm attempting to do everything I have the chance/necessity to do, in perl. Doing it in bash wouldn't be fun... I'm pretty good at bash ;)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1