[SOLVED] COMP9044 - Week 04 Weekly Test Questions

30.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (3 votes)

Create A File of Integers In Shell

Write a Shell program, create_integers_file.sh which takes 3 arguments.

The first & second arguments will specify a range of integers.

The third argument will specify a filename.

Your program should create a file of this name containing the specified integers.

For example:

Your answer must be Shell. You can not use other languages such as Perl, Python or C.

You are not permitted to use the Linux program seq.

No error checking is necessary.

When you think your program is working you can autotest to run some simple automated tests:

$ 2041 autotest shell_create_integers_file

When you are finished working on this exercise you must submit your work by running give:

$ give cs2041 test04_shell_create_integers_file create_integers_file.sh

Write a Perl program, create_integers_file.pl which takes 3 arguments.

The first & second arguments will specify a range of integers.

The third argument will specify a filename.

Your program should create a file of this name containing the specified integers.

For example:

$ ./create_integers_file.pl 40 42 fortytwo.txt

$ cat fortytwo.txt

40

41

42

$ ./create_integers_file.pl 1 5 a.txt

$ cat a.txt

1

2

3

4

5

$ ./create_integers_file.pl 1 1000  1000.txt

$ wc 1000.txt

1000 1000 3893 1000.txt

Your answer must be Perl only. You can not use other languages such as Shell, Python or C.

You may not run external programs, e.g. via system or backquotes.

No error checking is necessary.

 

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.