Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

create file with parameter 1

Status
Not open for further replies.

specv

Programmer
Aug 8, 2001
42
CA
Hi,
I have a script file that receive a parameters, the name of the file I want to create :

test.sh | date "+TEMPLATE_%Y%m%d"

In test.sh I want to create the file :

touch $1

But it not work.

Someone have idea?

Thanks
 
if your script contains

touch $1

from the command line

test.sh TEMPLATE_`date "+%Y%m%d"`

OR

test.sh TEMPLATE_$(date "+%Y%m%d")

should create a file TEMPLATE_20030702

JRjr
 
The pipe | is used to pass output from first command as an input to the another command, so:

test.sh | date "+TEMPLATE_%Y%m%d"

means that shell will execute the test.sh command and then will pass the stdout of test.sh as an stdin for date command. If you want to pass arguments, don't use pipe and do it as mi294r3 wrote.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top