LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   commands with variable (https://www.linuxquestions.org/questions/linux-newbie-8/commands-with-variable-774865/)

nagavinodh 12-10-2009 11:02 PM

commands with variable
 
hi,
how to assign the commands like ls ,find ,rm to variable in linux.

for ex:
i need to delete the log files automatically every day using crontab.

ghostdog74 12-10-2009 11:12 PM

Code:

var=$(command)

nagavinodh 12-10-2009 11:24 PM

hi,
thanks for reply.we got the following errors

[root@ebs httpd]# c=$find . -name *.txt
-bash: .: -n: invalid option
.: usage: . filename [arguments]
[root@ebs httpd]#

bsat 12-11-2009 12:12 AM

could not understand what are you trying to do there.
If you have assign the result of a command to a variable please use the format specified by ghostdog74, put the whole command in the brackets, preceded by a $.


All times are GMT -5. The time now is 07:19 AM.