I am building a rudimentary logging script, and want to capture the output of ps up 12345So far I have:DATE2=`date +%Y-%m-%d:%H:%M:%S`echo ${DATE2} >> $filenameps up 12345 --no-headers >> $filenameThis gives me the information I want, but on three lines (1=the date, 2=the output of ps 3=a blank line)However, ideally I would like to capture these on one line. Is there a way to combine them (and ignore the blank line)?
Output both ps and Date on one line, to a file?
debian;date;ps
You can save ps output to variable, too, and write it using one echo or printf.DATE2=`date +%Y-%m-%d:%H:%M:%S`PS_RESULT=`ps up 12345 --no-headers`printf %s: %s ${DATE2} ${PS_RESULT} >> $filenameSide note, it might be useful to get accustomed to $(command) instead of `command` when you can use it, as this syntax can be nested.