how to generate tabular (column) report from a text file

HI Experts,
Would like to generate tabular report from a text file using bash script.
Have attached the sample text file (test_job_tasks.txt) for reference.

Have attached the output Report (output_task_report.txt) format, that I'm requesting as well.

please help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You can adjust the numbers i.e column size according to your requirements.

awk '{printf "%-30s|%-18s|\n",$1,$2}'  test_jobs_tasks.txt > output_task_report.txt

Open in new window

enthuguyAuthor Commented:
Thanks sachiek,

for some reason, I get attached output
Try this way.

awk 'ORS=NR%12?" ":"\n"' test_jobs_tasks.txt > output_task_report.txt
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

enthuguyAuthor Commented:
Thx again, Looks better (attached the file for reference)

or is it easy to display only 4 fields
Yes, lesser columns means it look better.

awk 'ORS=NR%4?" ":"\n"' test_jobs_tasks.txt > output_task_report.txt
enthuguyAuthor Commented:
Is it possible to pick the required fields pls? right now it takes the first 4 fields
If you want that way first you need to filter out that with some kind of code like below.

while read line1; do
  read line2
  read line3
  read line4
  read line12
  echo $line1 <only put required lines to this temp file >  >> output1.txt
done <file 

Open in new window

Once done then use above awk command.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
enthuguyAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Shell Scripting

From novice to tech pro — start learning today.