[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

Text Format in Linux

Hello Expert,
Can you help with the formatting of the chkconfig --list command I need to make nice straight columns and also make 3 columns out of the cinetd section at the end. Also could you suggest how to get most system information and format that as human readable for reports. Thanks Joel
0
JoelRidley
Asked:
JoelRidley
  • 4
  • 4
3 Solutions
 
ahoffmannCommented:
chkconfig already prints nice (tabular) columns
if you want  3 out of the usual 2 columns, you need to tell us what shoulod be the third one

Or you're talking about another "chkconfig", then please post an example of your output.
0
 
JoelRidleyAuthor Commented:
Hello ahoffman,
yes the chkconfig does a nice jib but there are three rows where it shifts the text over because the what service parameter is longer than the rest. the xinetd is a single column and if you chkconfig --list | tr " " . | fmt -uw 70 > /filename the xinetd single column is now three, unfortunatly the whole text file is word wrapped. The idea is tpo run the script on each machine and then scp the results to a single location. A requirement (not mine) is that the output of the script be formatted so the that it is easily read without printing the scripts output. I was assigned the task unfortunately. Thanks, Joel An after thought I don't have to use chkconfig. I need kernel version how much memory in the machine, date cpu, interrupts services that are running and users and groups devices hard drive size video card. I think it wants a belarc for windiws type report. thanks again Joel
0
 
JoelRidleyAuthor Commented:
apologies ahoffmann Jpel
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ahoffmannCommented:
for formating use something like:
 chkconfig --list|awk '(NF==9){printf("%40s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5,$6,$7,$8,$9)}'

but that still cannot solve to "forge" the missing third column
0
 
JoelRidleyAuthor Commented:

Hello ahoffman,
tried your suggestion and redirected output to file and all I get is an empty file, did I miss something? thanks Joel
0
 
ahoffmannCommented:
# try:
 chkconfig --list|awk '(NF==8){printf("%40s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",$1,$2,$3,$4,$5,$6,$7,$8)}(NF==2){printf("%40s\t%s\n",$1,$2)}'
0
 
JoelRidleyAuthor Commented:
Hello ahoffmann,
Your solution is perfect, did exactly what I needed.
grade "A" and 500 points are yours. Thanks again Joel
0
 
ahoffmannCommented:
glad to have given a usefull answer to an unclear question ;-)
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

  • 4
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now