bash: passing asterisk to variable command
Hello, I want to pass asterisk to a variable:
Code:
#!/bin/bash any idea! |
I'm not grasping what you are doing...
The first statement assigns <<something>> to the variable named "log". What is the second statement supposed to do? If you are trying to add a literal "*" to the contents of log, have you tried escaping it? ls -l $log\* ls -l stuff* ##lists the contents of all directories with names beginning with "stuff" ls -l stuff\* ##lists the contents of the directory named literally "stuff*" |
Hello, i escape the asterisk with slash but didnt work.
Quote:
Quote:
|
Hmmmmm.....back to my original question: What are you trying to do?
|
I modify a script to audit apache config on AIX
this is the script: Code:
#! /bin/bash |
Sorry, that does not tell me anything......I'm quite elderly, and have a limited attention span. Going back to your original post, I simply need to know what "ls -l $log*" is supposed to do (in the context of the problem you are trying to solve.)
|
Hello,
this line will grep the apache error_log path Quote:
Quote:
Quote:
Quote:
Quote:
my question is how to make the asterisk work with variable $log, it work fine if i put $log as: Quote:
|
The line "ls -l $log*" doesn't pass anything to a variable.
If you need to separate the part that is a variable name from what follows, put the variable in brackets: ls -l ${log}* Since this is a script, you might want to include the full path to the ls command so that you don't run an alias instead. Check that the value of $log is what you think it is. |
ls -l ${log}* didnt work, i wont to use this script on many AIX systems and the apache config for them is different.
|
Sorry, but I just tried this and it works fine for me:
Code:
# in script |
Creak, squeek, groooooooooan....
(sound of brain trying to figure this out.......) I made five directories--dir1 thru dir5. In each one, I put a file (in dir1: file1, etc.) Code:
[mherring@Ath ~]$ name=dir |
If you add an echo you can see what is being resolved as $log:
Code:
#!/bin/bash Code:
bash-3.00# sh -x ./script.sh |
What is your shell options set to? Just as an example:
Code:
[jc@home ~]$ test=test |
hmmmmm guys, i just went back to home and test the script on my linux machine, its work fine!!!
it seem the issue is from the AIX bash3. strange i will search and read about bash scripting under AIX. Thanks guys for your help. |
Wow ... A Bash shell error held 7 people hostage ...
Don't you just love it when that happens!!! :D Linux |
All times are GMT -5. The time now is 09:14 AM. |