• Post Reply Bookmark Topic Watch Topic
  • New Topic

Parsing the Unix command output  RSS feed

 
Parshuram Walunjkar
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
I want to parse the out put of Unix command like df, ps -ef.
While returning output of those command there is no column separator in the output only empty space is used as delimiter.
But my data contains space, so it is giving problem while parsing.

Does any body suggest their view.
Waiting for reply,

Thank
Parshuram
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Either investigate whether the format is fixed, meaning all columns always take up the same number of characters (in which case it's easy to extract the columns), or see if the columns can be separated by content. E.g., some columns can only contain numbers and can't have white space. You could try to come up with a regular expression that describes the format of a line that way.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!