School of Physics, Mathematics, and Computing 
Not logged in (login)

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

Before posting a question here, you might want to search the forum for previous posts asking the same question.
And please keep the discussion civil (as required by UWA's Computer Use Policy, #9).

RSS cloud
Jump to:

awk command deleting blank spaces

1 of 108 articles shown, currently no other people reading this forum.
From: Muhammad A.
Date: Sun 11th Apr 2021, 2:57pm

suppose I have the file (example1) which contains the following:


I am trying to use awk to put the second line of the file into a variable. I am doing 
this by:

line2=$(awk 'NR==2 {print; exit}' < example1)

however when I try to do:

echo $line2

the outcome is: 


is there a way I can keep the blanks lines as well thanks


Related articles

awk command deleting blank spaces (both) RSS
├─ THIS   Sun 11th Apr 2021, 2:57pm, Muhammad A.
└─ reply 1   Mon 12th Apr 2021, 10:30am, Arran S.
This Page

Program written by: [email protected]
Feedback welcome
Last modified:  6:26am Aug 12 2021