PLEX86  x86- Virtual Machine (VM) Program
 Plex86  |  CVS  |  Mailing List  |  Download  |  Linux  |  Newsgroups

My first Bash script : trouble with * 3354


Your Ad Here

Your Ad Here

On Tue, 12 Apr 2005 22:35:39 +0200, Vincent Schmid staggered into the Black Sun and said:

Check the bash scripting guide at little advanced for you right now.

? Why bother with making it readonly?

mkdir temp if test -e temp-* ; then echo "not empty" ; else echo "empty" ; fi touch temp-test if test -e temp-* ; then echo "not empty" ; else echo "empty" ; fi touch temp-test2 if test -e temp-* ; then echo "not empty" ; else echo "empty" ; fi barf

...test expects *one* operand. * can expand to multiple operands. So...

...er, what are you trying to do here?

The shell expands glob patterns. "echo *" will show all the files in the current directory. "echohome-*" will show all the files inhome. When you do "wc *.txt" , the shell expands the * , and what actually gets executed is "wc file1.txt file2.txt file3.txt" . This is how things have worked for a long, long time.

My first Bash script : trouble with * 3355
On Wed, 13 Apr 2005 20:26:53 +0200, Vincent Schmid staggered into the Black Sun and said: You can do this without a problem. bash expands glob patterns, though. Escape the * . "echo*" will...

You could always do it like so:

R=`lspath-to-somewhere wc -l` if $R == "0" ; then echo "empty" ; else echo "not empty" ; fi

NTP daemon not synchronizing
I seem to be unable to get ntp to work with Slackware 10.1, and I just want to find out if...

...bash's syntax for logical operations like these is a bit annoying IMHO, but you can do it. Note that this fails if there are files whose names begin with a . in the directory. There is an option you can feed to ls that'll solve that problem; that option is in the man page and is not -a. There may be more efficient ways to do this, but this does seem to work.

bash is useful, but there are things that are easier to do in other scripting languages. Text manipulation, math, and semi-complex data structures are easier to deal with in Perl than they are in bash, f'rexample. Just make sure to pick the right language for the problem you're trying to solve, and you'll be happier and get the job done faster. HTH,

-- Matt GThere is no Darkness in Eternity-But only Light too dim for us to see Brainbench MVP for Linux Admin mail: TRAP + SPAN don't belong



Your Ad Here

List | Previous | Next

My first Bash script : trouble with * 3355

Linux groups from Newsgroups

The #1 Usenet Provider on the Internet

My first Bash script : trouble with * 3353