adding contents of a variable to a command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting adding contents of a variable to a command
# 1  
Old 02-07-2005
adding contents of a variable to a command

hi all,

i'm new to shell scripting, so i'm not sure how to work this. Is it possible to read in the contents of a variable and add it to a command? for example:

------------------------
#!/bin/sh

set example = -dfr

rm ${example}
------------------------
when i run the script, i want it to do a rm -dfr. Right now, it doesn't seem to work, and i'm not sure what i'm doing wrong
# 2  
Old 02-07-2005
Use the syntax:
example="-dfr"

No spaces around the equal sign.
# 3  
Old 02-08-2005
Bug

thanks, that was helpful
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Sorting the contents of a variable

i want to reduce the OPTIONS variable which is a list of email addresses to just the unique entries. The following works, but, i would like to accomplish it without using the temporary file (dest.txt) $echo $OPTIONS a b c A B D ... (5 Replies)
Discussion started by: jgt
5 Replies

2. Shell Programming and Scripting

Select command with variable options having spaces or null contents

Hi, I'm having an issue trying to produce a hierarchical directory menu that has either any directories listed in a specific directory as options or options with spaces in the option content or null content. So the menu function gets passed a base directory, it then lists any .sh scripts in... (6 Replies)
Discussion started by: andyatit
6 Replies

3. Shell Programming and Scripting

Folder contents getting appended as strings while redirecting file contents to a variable

Hi one of the output of the command is as below # sed -n "/CCM-ResourceHealthCheck:/,/---------/{/CCM-ResourceHealthCheck:/d;/---------/d;p;}" Automation.OutputZ$zoneCounter | sed 's/$/<br>/' Resource List : <br> *************************** 1. row ***************************<br> ... (2 Replies)
Discussion started by: vivek d r
2 Replies

4. Homework & Coursework Questions

How to read contents of a file into variable :(

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to read the contents of each field of a file creating user accounts. The file will be of format : ... (6 Replies)
Discussion started by: dude_me5
6 Replies

5. Shell Programming and Scripting

how to grep the contents of a variable..

Hello All, I've written a script to collect all audit logs files; now i want to see only the files from it which contains certain x tablenames. I've stored all the tablenames in a log file and using it through variable in a script (ex:below) $ more tablenames.log (this is just a samle... (2 Replies)
Discussion started by: suri.tyson
2 Replies

6. Shell Programming and Scripting

Storing the contents of a file in a variable

There is a file named file.txt whose contents are: +-----------------------------------+-----------+ | Variable_name | Value | +-----------------------------------+-----------+ | Aborted_clients | 0 | | Aborted_connects | 25683... (6 Replies)
Discussion started by: proactiveaditya
6 Replies

7. Shell Programming and Scripting

unique sort contents of a variable

Hi , I have #echo $var1 #hdisk2 hdisk3 hdisk0 hdisk2 Now I need to remove duplicate entries from this . ie. after sorting it should only have hdisk2 hdisk3 hdisk0 . I can have these values in a array as well . I understand we can use sort -u to remove the duplicates in a... (2 Replies)
Discussion started by: praveenbvarrier
2 Replies

8. UNIX for Dummies Questions & Answers

Save contents of a Variable

I want to save the contents of a variable to a file. How can that be achieved? I have tried with: echo $varname > textfile.txt but for some reason it does not print anything. (1 Reply)
Discussion started by: carl_vieyra
1 Replies

9. UNIX for Dummies Questions & Answers

adding contents of file

for example i have a file which contains data like: 123 222 325 142 can anyone help me write a script that adds them? let's say that "total" is the filename... (4 Replies)
Discussion started by: dakid
4 Replies

10. Shell Programming and Scripting

How to adding the filename into file contents

Dear Experts, Please help to teach me how to add the filename into the file content so that i can get the output below:- Actually the file name ***************New output that I want*************** =====2005-11-12===== EVENTS-20050912 03:33:37 ALARM: BTSSPAN-277-1 30-18013... (2 Replies)
Discussion started by: missutoomuch
2 Replies
Login or Register to Ask a Question