how to echo the file contents LINE BY LINE

hello,
i have a listing (let say ABC) consists of the below:

   :

public database link
public synonym
role
rollback segment
:

when i run the below for loop,
for i in `more ABC`
do
echo "$i"
done

it gives me,
:
public
database
link
public
synonym
role
rollback
segment
: :cool:

but what i actually need is,

   :

public database link
public synonym
role
rollback segment
:

appreciate if anyone out there know how to accomplish this.
any feedback is much appreciated.
Thanks in advanced. :slight_smile:

while read line; do
  echo "${line}"
done < ABC

Cheers
ZB

thanks, ZB

here's my script:

> gen_stmtaud.sql
grep -v '-' stmt_auditing_opt.lst|cut -c 1-200 > ABC
while read line; do
echo "audit ${line} by user by access;" >> gen_stmtaud.sql
done < ABC

the result i have for gen_stmtaud.sql is:
:
:
audit public database link by user by access;
audit public synonym by user by access;
audit role by user by access;
audit rollback segment by user by access;
:
:
audit by user by access;
audit by user by access;

but how am i AVOID getting those lines (in bold as shown above) resulting from blank lines in ABC? any idea?

Hi,

1)Try removing blank lines from ABC before processing, using the following command,

awk NF ABC > ABCwithoutblanklines

2) Use "if" to check whether $line is blank

Gaurav

yes! Gaurav, thanks a lot. :slight_smile: