Perderabo has always told you how to solve the find problem - sorry for my sloppiness.
I'm the one who is sorry.. Sorry at coding That line was a big help!
Quote:
Originally Posted by bakunin
Still, the above lines give me headaches: why use two different tools for a purpose where one would suffice?
does the same.
bakunin
Just my misunderstanding of what you said earlier.
I thought you meant that any time that a .* was used,
it would be safer to use a pipe. This Awk/Sed example by Trumpen was
the only thing I could find that did what I wanted.
After re-reading your post I now understand that it is meant
only for input.
I'm in the middle of adding the error checks mentioned earlier, After I
get it done, I will put it up here for other's to peruse and/or use as needed.
I thought you meant that any time that a .* was used, it would be safer to use a pipe.
This concept is a bit hard to grasp, because an asterisk is seemingly the same as an asterisk. No, that isn't the case.
There are regular expressions which are interpreted by regexp-using programs: sed, awk, grep, ed, vi, ... In this set of regular expressions a "." stands for "any character" and the asterisk stands for "0 or more of the last expression". ".*" means therefore "any number (including 0) of any character" and will therefore match any string whatsoever. Its the "real big joker", so to say.
But all these regexps deal with *string* manipulation. You feed a string to the program and this regexp will decide if the string matches or not. In this regard awk, sed and the others work basically the same way: if the string matches (of if it doesn't match) then a certain action is performed on this string, otherwise it isn't. (If i got you interested: Dale Dougherty wrote an excellent book, "sed & awk".)
Something entirely different are *shell* wildcards. They are some sort of regular expressions too, but their meaning is another. In this set of regexps the asterisk means "any number of any characters", similar to ".*" above.
The reason, why shell expansion poses a risk is the following: suppose a commandline like
In OSes like DOS the options ("-l", "*txt") would be passed to the program, in this case the executable "ls", and ls would have to figure out if a filename matches the schema and should be displayed or not. Not so in Unix: the shell (the program you type the command into) itself will expand the wildcard and replace what you have typed by what is matched by what you typed.
Suppose there are two files "a.txt" and "b.txt" in the directory and you issue the above command. First the shell will notice the wildcard, look into the directory and find 2 files which match it. Then it will replace your command with:
and this is, what ls will finally see. If you had entered the command this way yourself ls would not be able to tell the difference.
Now, suppose you would enter the same command in a directory where several hundreds of files matching the wildcard reside. The commandline would become pretty long, yes? Unfortunately the commandline has a limit (4k characters) and ls has also a limit. More than a certain number of arguments will not be digested. "Too many arguments" or "Argument list too long" reads the error which will be displayed then.
In Bash shell - the ps -ef shows only the /bin/bash but the script name is not displayed ? Is there any way to get the script names for the process command ?
--- Post updated at 08:39 AM ---
in KSH (Korn Shell), my command output shows the script names but when run in the Bash Shell... (3 Replies)
So I'm trying to pass certain json elements as env vars and use them later on in a script.
Sample json:
JSON='{
"Element1": "file-123456",
"Element2": "Name, of, company written in, a very weird way",
"Element3": "path/to/some/file.txt",
}'
(part of the) script:
for s... (5 Replies)
How to run several bash commands put in bash command line without needing and requiring a script file.
Because I'm actually a windows guy and new here so for illustration is sort of :
$ bash "echo ${PATH} & echo have a nice day!"
will do output, for example:... (4 Replies)
In the bash below I am asking the user for a panel and reading that into bed. Then asking the user for a file and reading that into file1.Is the grep in bold the correct way to apply the selected panel to the file? I am getting a syntax error. Thank you :)
... (4 Replies)
# check host value regex='^(||1|2|25)(\.(||1|2|25)){3}$' if ')" != "" ]; then if ]; then echo host $host not found exit 4 fi elif ]; then echo $host is an invalid host address exit 5 fi
espeacailly the top regex part?
---------- Post updated at 06:58 PM ---------- Previous update was... (1 Reply)
I have the following code and for some reason when I call the program using
/home/tcdata/tatsh/trunk/hstmy/bin/bash/raytrac.bash --cmod=jcdint.cmod
I get
hasArgument =
hasArgument = true
Somehow the array element is returning even though I have not chosen the option.
... (41 Replies)
hi,
i have a script that runs on bash and would like to run it on a machine that has csh and bash. the default setting on that machine is csh. i dont want to change my code to run it with a csh shell. is there any way i can run the script (written in bash) on this machine? in other words is there... (3 Replies)
Hi,
I use AIX (ksh) and Linux (bash) servers. I'm trying to do scripts to will run in both ksh and bash, and most of the time it works. But this time I don't get it in bash (I'm more familar in ksh).
The goal of my script if to read a "config file" (like "ini" file), and make various report.... (2 Replies)