declaring the variable doubt in shell

Issues related to applications and software problems
Post Reply
knzzz
Posts: 157
Joined: 2017/02/25 12:41:42

declaring the variable doubt in shell

Post by knzzz » 2019/10/07 17:30:57

Hi Team,
my question is how to declare the out of dt in the path have clarification in the last line

pt = "/path/of/the/file.txt"

dt=`date`

echo "$dt" >> $pt

Regards
Kanna

aks
Posts: 3073
Joined: 2014/09/20 11:22:14

Re: declaring the variable doubt in shell

Post by aks » 2019/10/08 17:08:29

Eh? What?

In "shell speak" you should get the output of the date command appended in the file /path/of/the/file.txt (assuming path exists, have write permission se labels and so on).

You don't "declare" output types (although you can declare variables).

tunk
Posts: 1205
Joined: 2017/02/22 15:08:17

Re: declaring the variable doubt in shell

Post by tunk » 2019/10/09 09:26:24

This works:
#!/bin/bash
pt="test.txt"
dt=`/usr/bin/date`
echo $dt > $pt

knzzz
Posts: 157
Joined: 2017/02/25 12:41:42

Re: declaring the variable doubt in shell

Post by knzzz » 2019/10/09 15:58:08

thank you it worked

User avatar
Errosion
Posts: 43
Joined: 2014/12/03 19:58:02

Re: declaring the variable doubt in shell

Post by Errosion » 2019/10/09 18:50:14

You could also do:

#!/bin/bash
pt="test.txt"
echo $(/usr/bin/date) > $pt

Post Reply