• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 314
  • Last Modified:

sh syntax

I am getting a script (in *unix) to output to file using the following:
/usr/local/bpc/bids2login -l <username> -f /etc/bpc.login.pw 2>&1 > <log> &
where log is of course the specified name of the log file... Now here's the question.. say I want the log file name to be date stamped.. so the log file name would end up being, for example, bids2login02030.log..  how would I modify the above command line to do that? I tried reading the sh man but its in typical unix speak :)
  • 2
1 Solution
use date command logFileName'date+"%d%m%y"'
this will name the file logFileName190601
for more options on the date comment just do a man date
missy041598Author Commented:
Would you be able to provide me with the new command I should use incorporating the above.
/usr/local/bpc/bids2login -l <username> - /etc/bpc.login.pw 2>&1 > bids2login`date+"%d%m%y"`
notice there are not single quotes, ticks, it the back-tick, located in the same button as the tilde ~, it tells the shell to execute the command first and then produce the string, so your system will resolv date+"%d%m%y" as 200601 then your log will be bids2login200601
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now