- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: How to align the space between column in outpu...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 04:31 AM
тАО05-29-2009 04:31 AM
Re: How to align the space between column in output of the script.
If you got proper solution please go ahead and closed this thread
Regards
Sunny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 05:15 AM
тАО05-29-2009 05:15 AM
Re: How to align the space between column in output of the script.
The details provided show that this is caused by duplicate entries in /etc/passwd. The solution (IMHO) is to fix that instead of using some workaround in your script. Fix the core problem for all!
I must admit to a weakness in my suggested solution approach. As written it does not report trying to enter a username entry when one exists. It would have worked without alerting you to the problem with /etc/password.
Viktor>> Hein, nice coding! But can we call this
"du -sk * | sort -rn" thing inside of awk? ;)
Thank you!. I try. As Dennis says, yeah you could, but why. I preferred to keep is outside as it seemed to me that it woudl be the most variable part. It allows you to drive the same report with different data sources. Maybe sorted differently, maybe cobbled up together from multiple intermediate files.
fwiw,
Hein.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 05:31 AM
тАО05-29-2009 05:31 AM
Re: How to align the space between column in output of the script.
Dennis suggested:
# givenname=$(grep "^$uname:" /etc/passwd |
awk -F: 'NR == 1 { gsub(",", "", $5); print $5 }')
...but I so dislike 'grep' piped to 'awk' --- as it uses an extra process (the 'grep') when 'awk' can do it all! Hence:
# givenname=$(awk -F: -v uname=${uname} '$1~uname {gsub(",","",$5);print $5}' /etc/passwd)
...which enables exact matches and eliminates the need for a 'tail -1' or testing for one record in the 'awk' too!
By the way, I also dislike using 'uname' as a variable name since it is the name of a command.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2009 12:53 AM
тАО05-30-2009 12:53 AM
Re: How to align the space between column in output of the script.
Oops, spent so much time removing cut, sed and head, forgot about grep.
>eliminates the need for a 'tail -1' or testing for one record in the 'awk' too!
Why do you say that? If /etc/passwd has two identical records, your script will find both.
Easily fixed by:
givenname=$(awk -F: -v uname=${uname} '$1 ~ uname {gsub(",","",$5); print $5; exit}' /etc/passwd)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2009 04:51 AM
тАО05-30-2009 04:51 AM
Re: How to align the space between column in output of the script.
> Dennis: If /etc/passwd has two identical records, your script will find both.
Ah, now I see what you were originally saying. Senthil's 'passwd' file actually has identical account name records. My comment was focused on the fact that we would match exactly on account name; not that there might be multiple instances. I agree that an 'exit' in the 'awk' after a match is the most performance satisfactory solution. Using a piped 'tail' merely adds another process.
> Senthil, I would 'vipw' your 'passwd' file and _eliminate_ the duplicate accounts. Unfortunately running 'pwck' will not uncover them.
> Dennis > JRF: but I so dislike 'grep' piped to 'awk'. Oops, spent so much time removing cut, sed and head, forgot about grep.
That's OK, you found a similar one that I had missed for the same reason in another thread :-}}
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-30-2009 05:17 AM
тАО05-30-2009 05:17 AM
Re: How to align the space between column in output of the script.
My problem is solved.
So i am closing this.
- « Previous
- Next »