| PLEX86 | ||
|
My first Bash script : trouble with * 3353"Vincent Schmid" Simply SOURCEPATH=-home-source will do Although, by convention, all caps is reserved for environment variables, so something like this would be better: SOURCEPATH or SourcePath My first Bash script : trouble with * 3354 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... Try this at the commandline: set If the list is too long, do: set less
Test is also in bash. And it expects a single argument, not the list of files that bash will return when it expands "*". Try this at the commandline: echo * and help var=$(findhome-source -maxdepth 1 ! -name ".*" wc -l sed 's-^ *--') find will list the files (including directories, which are also files) but not any "." ("invisible") files and not the contents of the subdirectories; the output of find is piped to wc -l will count the number of lines in find's output, one file per line; this figure is piped to sed to clean up the leading spaces that wc outputs. The "$( )" means to echo the output of whatever command(s) is inside them. "` `" does the same thing (backticks). If you wish to list just regular files, put "type -f" afterhome-source. If you want to list all the files in the subdirectories (if any), remove the "-maxdepth 1". If you want to list the "." files, then remove the "! -name ".*". (You'll find the "." files with ls -a.) If you use ls instead of find, the number will be one over the number of files and dirs. if -z "$var" then #commands here, one per line fi If the content of $var is an empty string, do something. Which seems to be what you are getting at. I think I see a windoze-dos programmer that has finally come to his senses and is learning nix. Good for you. AC -- Genuine Usenet Kook:
|
||||
My first Bash script : trouble with * 3354 Linux groups from Newsgroups The #1 Usenet Provider on the Internet
|
||||