The problem I encountered was that wildcards *were* expanded when I didn't want them to be. If exclude="C *.txt" then "for i in ${exclude}" expands the asterisk in *.txt to a list of .txt files in the current directory, rather than passing the string "*.txt" to tar. I couldn't see an easy way around it, hence the eval. Happy now or still hate it?
As it is "eval" won't help you avoid this problem, but in fact make it worse. Without "eval" your command line becomes interpreted by the shell once, with it twice. I don't think "eval" should be avoided generally (like you seem to believe Corona688 is thinking), but in this case it is simply the wrong tool - and probably very dangerous, as Corona688 pointed out correctly.
If you want to avoid interpretation of a certain string use quotation - that is, what it is for. For intance:
Now, let us apply this to your problem. I use ":" as a delimiter here, like in the PATH variable, because commas or something such could be used in filenames and i want to avoid that:
I would like to say for the record, that i don't think the contents of the variable excludelist should be modified by modifying the scripts text at all. Instead a configuration file should be passed to the script, which contains all the exclusions. How to construct a syntax for such a configuration file and how to parse it i have described here, but the way of feeding the options to tar will still be as lain out here.
Hi,
I am new to shell scripting.I have worked somewhat with Perl though.
I am not able to find what the second line does and how does it do.
<code>
FP_RUNNING=`service filepool status`
FP_RUNNING=${FP_RUNNING%% *}
<\code>
After the first line,the variable FP_RUNNING stores '1 FilePool... (2 Replies)
Hi,
Im pretty new to Unix. I came across a script which was using PLSQL inside a script and there was an unusual thing mentioned.
there was a variable assigned as
P_CUR=${1}
and one more as
V_TAGFILE="$1"
Couldnt find the difference. Also the variables were used in PLSQL... (1 Reply)
Must be a bug or something. Whether I escape them or not, it will not work. No matter what I set the minimum and maximum to nothing gets caught. For instance:
find / -regex "/.{0, 50}.*" -maxdepth 1 or find / -regex "/.\{0, 50\}.*" -maxdepth 1 should pretty much catch everything residing within... (4 Replies)
Hi everyone:
I'm stuck at this point, could you guys please give me some hints about what I am doing wrong in the following script, I'm using sed for windows:
sed ^"$ {^
a^
STRINGTABLE DISCARDABLE^
BEGIN^
#define CLIENT_MODULE, "%CLIENT_MODULE%"^
#define CLIENT_ID, "%CLIENT_ID%"^... (1 Reply)
Hi everyone,
I've got a file that looks like this:
uid{508}pid{22224}pname{/PPROGRAM/pprgramx -profile:LIVE -serv:as ...
I want to pull the value of pid between the curly braces, or 22224 in this example. pid is always the second pair of curly braces, but the length of the number is... (7 Replies)
Hi Everyone,
in the below "xyz (Exception e)" part... after the curly braces, there is a new line and immediately few tabs are present before closing curly brace.
xyz (Exception e) {
}
note: there can be one or... (1 Reply)
Hi Everyone,
in the below "xyz (Exception e)" part... after the curly braces, there is a new line and immediately few tabs are present before closing curly brace.
xyz (Exception e) {
}
note: there can be one or more newlines between the curly braces.
My desired output should be ... (6 Replies)
Hi,
I have below command in one of the script. Can you please let me know what does the curly braces do over here \{1,\}. The remaining part of the code atleast I am able to understand.
sed -n 's/.*\-\()\{1,\}\)\-.*/\1/p' (13 Replies)
Hello, i was trying to find get a command to list duplicated files so i tried
ls dir1 dir2 | awk '{x++}'
and it didnt work.
After a bit of searching online i found that it works without the curly braces
ls dir1 dir2 | awk 'x++'
I thought the curly braces were needed in awk so... (6 Replies)
file.txt
apple
apples{
applepicture
apple9
apple cake{
abple
apple_and_cake
appleapple
apple
apple(
and my script
while read line; do
if ]; then
echo "$line"
fi
done <file.txt
read (10 Replies)