# Qstat -f \<JOBID\> line breaks

**URL:** <https://community.openpbs.org/t/qstat-f-jobid-line-breaks/267>\
**Category:** Users/Site Administrators\
**Created:** [September 28, 2016, 8:42am UTC](https://community.openpbs.org/t/qstat-f-jobid-line-breaks/267 "2016-09-28T08:42:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![buchmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/buchmann/32/31_2.png) [@buchmann](https://community.openpbs.org/u/buchmann)\
**Post date:** [September 28, 2016, 8:42am UTC](https://community.openpbs.org/t/qstat-f-jobid-line-breaks/267/1 "2016-09-28T08:42:41Z")

</div>

Hi,

For various reasons, I need to parse information about jobs - such as getting the job comment (if any).  
In such circumstances, it would be convenient to get each job attribute on a single line - even if the line could be very long.  
The present full-format output breaks “long info” over several lines, adding extra spaces to subsequent lines, such as in:

```
    Submit_arguments = -l walltime=00:02:00 -l select=2:ncpus=2 -l place=scatte
        r:excl -- /bin/sleep 30

```

Is there a simple way (say a qstat flag), where I can get each attribute on a single line? Alternatively, just get a single named attribute? (I could write a script to do the reformatting, but I consider that a hack).

Many thanks,

/Bjarne

---

<div class="post-metadata">

**Author:** ![buchmann](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.openpbs.org/buchmann/32/31_2.png) [@buchmann](https://community.openpbs.org/u/buchmann)\
**Post date:** [September 28, 2016, 2:38pm UTC](https://community.openpbs.org/t/qstat-f-jobid-line-breaks/267/2 "2016-09-28T14:38:27Z")

</div>

Here is a hack to do it. It relies on the assumption that continued lines in qstat start with a single tab char ("\t") before the content. And that there are no blanks at end-of-line. Thus, we can simply delete all “newline-tab” combos from the `qstat -f` output.

This is not pretty (well, it’s pretty ugly), but it seems to work.

```
qstat -f | perl -e '$/=undef;$_=<>;s/\n\t//g;print $_'

```

**[EDIT:]**  
If you prefer `sed` over `perl`, then you can do stuff like:

```
qstat -f | sed ':a;N;$!ba;s/\n\t//g'

```

Anyway, to get just the Submit\_arguments (the full attribute, and only this attribute) of a single job, you may do stuff like

```
attrnam=Submit_arguments
qstat -f <JOBID> | perl -e '$/=undef;$_=<>;s/\n\t//g;print $_'\
   |grep "^\s\+$attrnam = "|sed -e "s/^\s\+$attrnam = //"

```

For my job, this outputs, on a single line:

```
-l walltime=00:02:00 -l select=2:ncpus=2 -l place=scatter:excl -- /bin/sleep 30

```

YMMV.

If somebody knows a “nicer way” - or even a secret/magic trick to get “wide lines” and “full output” with qstat, let me know (`-w` and `-f` don’t mix).

/Bjarne

**PS [EDIT]:** Just in case somebody is interested, I created a script to interface to qstat. It takes care of the “\n\t”-issue, and also can give you just the value of a single named attribute for a named job.  
[https://sourceforge.net/p/dcoo/cluster-tools/ci/master/tree/pbs/qstat2lin](https://sourceforge.net/p/dcoo/cluster-tools/ci/master/tree/pbs/qstat2lin)  
Obviously, all input/comments to improve the script is most welcome.
