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

help4407


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

Assignment 2 Q2

1 of 390 articles shown, currently no other people reading this forum.
photo
From: Christopher M.
Date: Fri 15th May 2020, 3:55am
Actions: 
        Login-to-reply

 

"Thanh Tang" <22*0*0*[email protected]*u*e*t*u*a*e*u*a*> wrote:

> When I used loop to print each line the file. It printed out 
> "10.4.0.14
> -
> -
> [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`
do
     echo $i
done
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 2020, 3:10pm, Mingbo Z.
├─ reply 1   Thu 14th May 2020, 3:48pm, Christopher M.
├─ reply 2   Fri 15th May 2020, 2:25am, Thanh T.
├─ THIS   Fri 15th May 2020, 3:55am, Christopher M.
├─ reply 4   Fri 15th May 2020, 12:32pm, Thanh T.
├─ reply 5   Fri 15th May 2020, 4:31pm, Mingbo Z.  O.P.
├─ reply 6   Fri 15th May 2020, 5:04pm, Mingbo Z.  O.P.
├─ reply 7   Fri 15th May 2020, 5:17pm, Christopher M.
├─ reply 8   Fri 15th May 2020, 5:19pm, Christopher M.
├─ reply 9   Fri 15th May 2020, 5:54pm, Mingbo Z.  O.P.
├─ reply 10   Fri 15th May 2020, 6:04pm, Christopher M.
├─ reply 11   Wed 20th May 2020, 3:33pm, Jordan M.
└─ reply 12   Thu 21st May 2020, 7:52am, Christopher M.
This Page


Program written by: [email protected]
Feedback welcome
Last modified: 11:27am Sep 21 2020