I would definitely not recommend parsing XML in bash (or any other language
that doesn't implement nested data structures), but Perl XML::LibXML has
been a handy library for implementing our custom parsing of q* XML output.
These days I would probably use Python or Ruby but I wrote our tools many
years ago so Perl it was...

On Thu, Aug 01, 2019 at 10:59:09AM -0400, David Trimboli wrote:
> Changing the names isn't an option; I inherited these names years ago and
> nobody's going to want me to change them because I want to see something in
> order. :)
> 
> Basically, I can run this command to see it the way I want it:
>     qhost | head -n 3; qhost | tail -n +4 | sort -V
> but of course this is cumbersome and makes adding options a chore. (Suppose
> I want to use -j?)
> 
> I guess XML it is. If this were PowerShell it'd be a cinch, but working in
> Bash... ugh...
> 
> On 8/1/2019 10:39 AM, MacMullan IV, Hugh wrote:
> > David,
> > 
> > Best for qhost sort would be to change your 'cluster' names to zero-padded, 
> > if you really want that kind of sorting. Or you could create an alias like 
> > 'qhost | sort -nk 1.8', assuming 'clusterX' is always true (the 8th 
> > character is where you start the sort).
> > 
> > As Skylar says, if you want a custom qstat, you should probably build one 
> > from the '-xml' output.
> > 
> > Regards,
> > -Hugh
> > 
> > -----Original Message-----
> > From: users-boun...@gridengine.org <users-boun...@gridengine.org> On Behalf 
> > Of David Trimboli
> > Sent: Thursday, August 1, 2019 9:59 AM
> > To: users Users <users@gridengine.org>
> > Subject: [gridengine users] Sorting qhost and choosing qstat columns
> > 
> > When I run qhost, the output is sorted alphabetically ??? which means
> > "cluster10" appears before "cluster2," and so on.
> > 
> > Before I go writing bash functions to manually sort this, which might
> > lead to output side-effects, is there any way to change the sort to a
> > natural number sort, so that "cluster2" would appear before "cluster10,"
> > etc.?
> > 
> > When I run qstat, the normal wraps to a second line in my terminal set
> > to 120 columns. I could fix that by eliminating the "jclass" column,
> > which doesn't contain any information, but I can only find ways to add
> > columns, not take them away. Is there a way to make this column go away?
> > 
> > _______________________________________________
> > users mailing list
> > users@gridengine.org
> > https://urldefense.proofpoint.com/v2/url?u=https-3A__gridengine.org_mailman_listinfo_users&d=DwIGaQ&c=mkpgQs82XaCKIwNV8b32dmVOmERqJe4bBOtF0CetP9Y&r=EKk3zFVROsf8w5OyB2T6u55jzploih3y7CaWIlGOLAY&m=m_wX_jPeroRg7CYImv_hhYP5_j4Yg77eKMrgzOYGdVY&s=pwdLspfOZXCXUKlxE7OGCCu9y5Pg8hqoWxsY3gcb6Ls&e=
> _______________________________________________
> users mailing list
> users@gridengine.org
> https://gridengine.org/mailman/listinfo/users

-- 
-- Skylar Thompson (skyl...@u.washington.edu)
-- Genome Sciences Department, System Administrator
-- Foege Building S046, (206)-685-7354
-- University of Washington School of Medicine
_______________________________________________
users mailing list
users@gridengine.org
https://gridengine.org/mailman/listinfo/users

Reply via email to