Linux – Concatenate string in Linux

linux

I am new to Linux and I am using command

watch "ps u -C appName >> logFile" 

to obtain the process info of appName and output into logFile.

However, it does not include the date time info.

I know that date command could return the date and time.

How could I insert the date command into the watch statement above so that the date would be included in the logFile for each watch command?

Thanks.

Best Answer

  • Since watch takes shell commands, give it a group command.

    watch "{ date +'...' ; ps u -C appName ; } >> logFile"