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.
When you think your program is working you can autotest to run some simple automated tests:
$ 2041 autotest perl_create_integers_file
When you are finished working on this exercise you must submit your work by running give:
$ give cs2041 test04_perl_create_integers_file create_integers_file.pl
It will be given two arguments n and the file name.
Your program should print nothing if the file does not have an n-th line You can assume n is a positive (non-zero) integer.
You should not assume anything about the lines in the file.
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.
When you think your program is working you can autotest to run some simple automated tests:
$ 2041 autotest nth_line
When you are finished working on this exercise you must submit your work by running give:
$ give cs2041 test04_nth_line nth_line.pl
Reviews
There are no reviews yet.