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
test_job_tasks.txt
output_task_report.txt
enthuguyAsked:
Who is Participating?
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.

sachiekCommented:
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

0
enthuguyAuthor Commented:
Thanks sachiek,

for some reason, I get attached output
output_task_report.txt
0
sachiekCommented:
Try this way.

awk 'ORS=NR%12?" ":"\n"' test_jobs_tasks.txt > output_task_report.txt
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

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

or is it easy to display only 4 fields
e.g
job_n_name
job_n_dependent_on
job_n_status
job_n_last_updated
output_task_report.txt
0
sachiekCommented:
Yes, lesser columns means it look better.


awk 'ORS=NR%4?" ":"\n"' test_jobs_tasks.txt > output_task_report.txt
0
enthuguyAuthor Commented:
Is it possible to pick the required fields pls? right now it takes the first 4 fields
0
sachiekCommented:
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.
0

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:
Thanks
0
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.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.