awk field separator not working

Hi, can some some help to get me the right results,

I have few text files, need to grep few columns from each file and get the results in one row with comma separated.
my code is

#folder=/nz/kit/log/backupsvr
folder=/export/home/nz/valai/tmpfiles/

echo $folder
for entry in `ls $folder` ; do
tac $folder$entry |sed -n '2p'|awk '{print $9}'
sed -n '3p' $folder$entry |awk '{print $14}'
sed -n '2p' $folder$entry |awk '{print $1, substr($2,1,8)}'
tac $folder$entry |sed -n '1p'|awk '{print $1, substr($2,1,8)}'
echo $folder$entry
tac $folder$entry |sed -n '3p'|awk  '{print $7}'\n
done

getting result as

backupsvr.73644.2020-01-16.log
861482765
PROD_LDA_STAGING
-differential
2020-01-16 20:09:53
2020-01-16 20:13:08

Need to result as

backupsvr.73644.2020-01-16.log,861482765.PROD_LDA_STAGING,-differential,2020-01-16 20:09:53,2020-01-16 0:13:08

please help, I tried with -FS in different options with no luck.

Thanks
Valai

1 Like

it could helpful if you provided a sample (simple) file and the description what column(s) need to be extracted.
Also having a sample input AND a desired output would be helpful as well.

Please use code tags when posting data and code samples!

2 Likes

To all
Please pay attention to what is displayed at the top of this discussion: We are awaiting a reply from the O/P any solution posted till then will be hidden

Thanks for your understanding

5 Likes

Thank you vbe,

Yes, this is the correct approach, especially when additional information is requested by a Moderator, in this case, vgersh99 .

It is important that posters, especially these "fly into the site, register, and post" users follow community guidelines and Moderator instructions.

Thank you very much vbe and vgersh99 for your dedication to helping the community and your well-developed moderation skills.

If the OP does not reply back in few days (your judgement call on how many days), then we can "unhide" the two solutions presented so far.

Thanks for the solutions and replies as well!

Good work everyone.