LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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-10-2009, 11:02 PM   #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-10-2009, 11:12 PM   #2
ghostdog74
Senior Member
 
Registered: Aug 2006
Posts: 2,697
Blog Entries: 5

Rep: Reputation: 244Reputation: 244Reputation: 244
Code:
var=$(command)
 
Old 12-10-2009, 11:24 PM   #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, 12: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 07: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 12:08 AM
Sed search for variable and delete entire line, but variable contains forward /'s Passions Programming 2 11-10-2008 03:44 PM
multiple commands assigned to bash variable itzamecwp Linux - Newbie 3 02-14-2007 06:40 AM
assigning commands to a variable aunquarra Linux - General 5 01-04-2006 07:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:59 PM.

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
Open Source Consulting | Domain Registration