LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   bash script file access question (https://www.linuxquestions.org/questions/linux-newbie-8/bash-script-file-access-question-746503/)

KBriggs 08-10-2009 01:09 PM

bash script file access question
 
Never mind, my mistake was a simple spelling error :)
thanks anyway

jvhiii 08-10-2009 01:47 PM

It's acting as though there are no directories that match the pattern *_potHermannSkillman* in the current working directory. I assume that you've already verified that these directories exist and the files you want to process are present. I suggest adding some debug code, like:

pwd
ls
ls *_potHermannStillman*

before the for loop.

-John

i92guboj 08-10-2009 01:54 PM

Using "#!/bin/bash -x" will probe useful the next time you run into a similar problem, it adds verbosity without having to insert debug echos everywhere in the middle of the script ;)

Also, when dealing with paths and the like, you should really do some basic checks at least in your code. Like these:

Code:

#!/bin/bash -x

input="output"
output="output"
output_file="${output}/ibh_log_graph.dat"

if [ ! -d "$input" ]; then
        mkdir "$input";
fi

if [ ! -d "$output" ]; then
        mkdir "$input";
fi

if [ -f "${output_file}" ] && [ -w "${output_file}" ]; then
        rm -f "${output_file}"
fi



All times are GMT -5. The time now is 01:33 PM.