LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-11-2009, 12:02 AM   #1
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Rep: Reputation: 15
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.
 
Old 12-11-2009, 12:12 AM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
var=$(command)
 
Old 12-11-2009, 12:24 AM   #3
nagavinodh
Member
 
Registered: Aug 2009
Posts: 118

Original Poster
Rep: Reputation: 15
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]#
 
Old 12-11-2009, 01:12 AM   #4
bsat
Member
 
Registered: Feb 2009
Posts: 347

Rep: Reputation: 72
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 $.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Executing commands through shell variable shriyer Linux - Software 2 07-23-2009 08:03 PM
AWK a variable Ouptut to a new variable and using the new variable with the old one alertroshannow Linux - Newbie 4 02-16-2009 01:08 AM
Sed search for variable and delete entire line, but variable contains forward /'s Passions Programming 2 11-10-2008 04:44 PM
multiple commands assigned to bash variable itzamecwp Linux - Newbie 3 02-14-2007 07:40 AM
assigning commands to a variable aunquarra Linux - General 5 01-04-2006 08:58 AM


All times are GMT -5. The time now is 08:36 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration