- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to align the space between column in output of...
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-28-2009 05:14 AM
тАО05-28-2009 05:14 AM
Re: How to align the space between column in output of the script.
change givenname as :
givenname=`grep ^"$uname:" /etc/passwd|cut -d: -f5` | sed -e 's/,//g'
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 05:19 AM
тАО05-28-2009 05:19 AM
Re: How to align the space between column in output of the script.
try this
givenname=$(echo "${givenname}"|sed -e 's/,/ /g')
Regards
Sunny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 01:22 PM
тАО05-28-2009 01:22 PM
Re: How to align the space between column in output of the script.
Hein, nice coding! But can we call this
"du -sk * | sort -rn" thing inside of awk? ;)
Unix operates with beer.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-28-2009 08:23 PM
тАО05-28-2009 08:23 PM
Re: How to align the space between column in output of the script.
>>Here I want the name only but not commas
There are 2 easy way to remove comma
1. open your output into vi
at the vi command prompt give this
:1,$s/,,,//gp
2. assum your output is in out.txt file
now give this command at comman prompt
#sed 's/,,,//'
Suraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 02:51 AM
тАО05-29-2009 02:51 AM
Re: How to align the space between column in output of the script.
Yes but why bother. ;-)
"du -sk *" | getline
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 03:35 AM
тАО05-29-2009 03:35 AM
Re: How to align the space between column in output of the script.
Thanks a lot now i am getting correct output that i want.
But some entries are repeating, i want to retain only one entry for each. so how to truncat the other entry.
A)My script:
#! /usr/bin/sh
cd /emd/home
printf "%-10s %-15s %-35s %-25s\n" "SPACE" "USERID" "USERNAME" "LINKED_DIRECTORY"
printf "%-10s %-15s %-35s %-25s\n" "-----" "------" "--------" "----------------"
du -sk * | sort -rn | while read space uname
do
#space=`echo $line | awk {'print $1'}`
#uname=`echo $line | awk {'print $2'}`
givenname=`grep ^"$uname:" /etc/passwd|cut -d: -f5|sed 's/,//g'`
linkdir=`ll -nd /emd/home/$uname | awk {'print $11'}`
printf "%-10s %-15s %-35s %-25s\n" "$space" "$uname" "$givenname" "$linkdir"
done
B)Output:
SPACE USERID USERNAME LINKED_DIRECTORY
----- ------ -------- ----------------
7436064 remoquil Soliman Remoquillo
5806320 pzhysl Jason Meyers
3069352 7en0fm Mark Herman
2033224 wabtec Wabtec sharedaccount
2032944 7e8e9u Steven Dettloff
1966224 paez
1888472 mentordata
1810456 infodba Iman Administrator
1650224 tek
1536368 reydl2 Matthew A Sawtell
1443248 redquest
1381032 nzr3k0 Nicholas Shim-Ping
103832 lzrxcl Emma Biddings ---------------------------> First time
Emma Biddings ------------------------------------------------------> second time
6544 oracle Oracle Administrator --------------------> First time
Oracle Administrator -----------------------------------------------> Second time
0 vz1fmk Ish Patel
0 tzrrzp Roopesh Shroff /emd/ansys2/tzrrzp
0 tpw /emd/tpw
0 tombers /emd/ansys1/tombers
0 svihla Gary Svihla /emd/ansys2/svihla
0 stdlib Standards Coord CDMS /users/stdlib
0 schueler /emd/ansys2/schueler
0 rz17by Maximo Test
C)I checked why they are comming two times:
1) 103832 lzrxcl Emma Biddings
Emma Biddings
root@lgapps:/root > grep lzrxcl /etc/passwd
lzrxcl:R1b5gn01B1VGU:1260:1002:Emma Biddings,,,:/emd/ansys2/lzrxcl:/usr/bin/sh
lzrxcl:R1b5gn01B1VGU:1260:1002:Emma Biddings,,,:/emd/ansys2/lzrxcl:/usr/bin/sh
2)6544 oracle Oracle Administrator
Oracle Administrator
root@lgapps:/root > grep ^oracle: /etc/passwd
oracle:oAx6JjE54AHZw:498:1010:Oracle Administrator,,,:/appl/oracle/dba/admin:/usr/bin/sh
oracle:oAx6JjE54AHZw:498:1010:Oracle Administrator,,,:/appl/oracle/dba/admin:/usr/bin/sh
I want only one entry for each directory.
Pls find the attachment for clear details.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 03:56 AM
тАО05-29-2009 03:56 AM
Re: How to align the space between column in output of the script.
Can you attached it once again????
Regards
Sunny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 03:59 AM
тАО05-29-2009 03:59 AM
Re: How to align the space between column in output of the script.
Thanks, that solves the mystery:
givenname=$(grep "^$uname:" /etc/passwd |
awk -F: 'NR == 1 { gsub(",", "", $5); print $5 }')
(Or you could stick a "head -1" in the pipe.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 04:02 AM
тАО05-29-2009 04:02 AM
Re: How to align the space between column in output of the script.
You can give head option in pipe like
head -1 if you want only one entry.
Regards
Sunny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-29-2009 04:27 AM
тАО05-29-2009 04:27 AM
Re: How to align the space between column in output of the script.
Thanks a lot.
Now everything is fine.