Faculty of Engineering and Mathematical Sciences 
Not logged in (login)


This forum is provided to promote discussion amongst students enrolled in Open Source Tools and Scripting (CITS4407).

Assignment 2 and Clarifications.
RSS cloud
Jump to:

Assignment 2 Q2

1 of 390 articles shown, currently no other people reading this forum.
From: Christopher M.
Date: Fri 15th May, 3:55am
"Thanh Tang"                               wrote:

> When I used loop to print each line the file. It printed out 
> "
> -
> -
> [03/May/2020:03:09:27 +0800]
> "GET
> /run/help2200?p=np
> HTTP/1.1"
> 200
> 42477"
> It is not on the same line. Does this question require us to do some data cleaning 
> before draw charts?

I cannot tell what you mean by "I used a loop...", as there are many possible ways.
But my guess is that you have something like:

for i in `cat filename`
     echo $i
This will not work as you probably hope, because placing a command in backquotes requests that all of its output is appended onto one long line, with each of its original lines now separated by spaces. Easily verified with a simple file of just 3 lines. If this is what you're doing, change from that "for i in ..." loop to one using ""while read line ; do ...." and the input lines will be preserved each time around the loop. Then *you* can break each line into its fields.

Related articles

Assignment 2, Q2 (all 13) RSS
├─ original   Thu 14th May, 3:10pm, Mingbo Z.
├─ reply 1   Thu 14th May, 3:48pm, Christopher M.
├─ reply 2   Fri 15th May, 2:25am, Thanh T.
├─ THIS   Fri 15th May, 3:55am, Christopher M.
├─ reply 4   Fri 15th May, 12:32pm, Thanh T.
├─ reply 5   Fri 15th May, 4:31pm, Mingbo Z.  O.P.
├─ reply 6   Fri 15th May, 5:04pm, Mingbo Z.  O.P.
├─ reply 7   Fri 15th May, 5:17pm, Christopher M.
├─ reply 8   Fri 15th May, 5:19pm, Christopher M.
├─ reply 9   Fri 15th May, 5:54pm, Mingbo Z.  O.P.
├─ reply 10   Fri 15th May, 6:04pm, Christopher M.
├─ reply 11   Wed 20th May, 3:33pm, Jordan M.
└─ reply 12   Thu 21st May, 7:52am, Christopher M.
This Page

Program written by: [email protected]
Feedback welcome
Last modified:  8:27am May 24 2020