Click to See Complete Forum and Search --> : Scripting and Perplexed??? help!!!!!


Huggy
12-08-2001, 12:57 PM
I get perplexed with the use of the backets and the tic's I'm not sure when to use which one or for what. can you please help me out.

Ok whats the deal with the { [ ( and " ' `

Start with the { [ (
whats the difference? where would you use one set as opposed to the other. and what are they really say to the program for example I copied this one out.
It shows all the ( { [ and the fast run by of this program is it scans the current dir for any .bsh file and echo them to the standered out, the screen as .txt but no changes or copies are made to the .bsh file.

#!/bin/bash
for src in $(echo *)
do
targ=$(echo $src | gawk -F"." '/.*[.]bsh/ {print $1".txt"}')
if [ $targ ]
then
echo cp $src $targ
fi
done

Huggy
12-09-2001, 03:04 PM
help still... please

stiles
12-09-2001, 04:50 PM
$(command) is the KSH and BASH form of command subsutition

`command` is the Bourne shell form of command subsutition

${} is used for substitution and pattern matching operators

double quotes makes everything between them parsed as a literal except $ and `

single quotes makes everyting between them parsed as a literal

[] is a metacharacter which matches any one character enclosed

() is a command grouping

{} is a command block

if [$targ]

is the same as saying (shorthand for test)

if test $targ

gawk (http://www.gnu.org/software/gawk/gawk.html) is a pattern matching program.

You need some reference material if your going to be scripting. Try reading this (http://www.linuxdoc.org/LDP/abs/html/). GNU (http://www.gnu.org/software/bash/bash.html) may has some references too.