Katacoda doesn't accepts my source code... why?

255 Views Asked by At

I was solving a unix problem on Katacoda. I am solving it as instructed but it gives me an error.

The problem is to display number of lines and words in a given input file
Write a command/logic, which will read the content from a given input file and display the number of lines and number of words in the file.

  • Your default logged in directory: /home/scrapbook/tutorial/
  • Input file location: /home/scrapbook/tutorial/unix_countproject/
  • Input file Name: input.txt
  • Script file location: /home/scrapbook/tutorial/
  • Script file Name: script.sh

Instructions:

  1. You can view content of input file (input.txt) in the folder at /home/scrapbook/tutorial/unix_countproject/.

    Note that this folder and file already exists and are located in the path mentioned above.

  2. You can open the script.sh file using vi editor, Write the logic inside the file to display the number of lines and number of words in the input file (input.txt), After writing the logic , save the file and quit from vi editor .

  3. To test your command/logic, Run the shell script file (script.sh) at the terminal using the below command

     sh /home/scrapbook/tutorial/script.sh
    
  4. If any issues while running the above command, Modify the script.sh file and repeat the point#:3

  5. Don't use any echo statement in the script.sh file, even in the commented line/code

  6. On completion of the task, click on SUMMARY or CONTINUE to proceed to next assignment.

Example : Contents of sample Input file named as input.txt - starting from following line

Hello all
Welcome to all of you

Expected Output:

2 7

As instructed, I store my logic in the script.sh file and it executes successfully and gives me the expected output but it's not accepting my answer.

$ cd unix_countproject
$ cat input.txt
Hi all
Welcome to Unix module
$ vi script.sh
Inside script.sh : wc -l -w input.txt|cut -c-6
(exit vi)
$ chmod +x script.sh
$ ./script.sh
 2 6

Then I click on complete but it's not accepting it.

0

There are 0 best solutions below