0

I aliased the following script:

#!/usr/bin/bash

if [[ -d "template.html" ]]; then
  :
else
  cp -n /home/$(whoami)/CS/Software/Pollen/template.html .
fi

/usr/bin/echo "#lang pollen



[1]: " > ${1}.html.pmd

with alias tmd="~/CS/Software/Bash/create_md.sh" in my .bashrc. The script does its job of creating a file in the current directory but it fails to create a file in a distant directory, I get from Bash: bash: /home/jim/CS/Software/Bash/create_md.sh: No such file or directory. Quoting, i.e. "${1}.html.pmd", has not resolved the matter. Yet echo typed in manually, e.g. echo "ana-echo">ana1/ana2/file.html.pmd does such job. Why is it so? How might I improve on the script (so that it does the job in distant directories as well)?

4
  • How do you run the script? What's the command? And what's the exact error message you get? Bash usually prefixes errors related to some file with the file name, doesn't that happen here?
    – ilkkachu
    Commented Feb 13, 2022 at 18:29
  • @ilkkachu I run the script by typing its alias, e.g. tmd ana1/ana2/file where ana1/ana2/ are the directories of the relative path to the file to be created . The error message is bash: /home/jim/CS/Software/Bash/create_md.sh: No such file or directory
    – John Smith
    Commented Feb 13, 2022 at 19:02
  • The error msg edited in lately clearly indicates that with your suspicion (ana1/ana2/file) you're barking up the wrong tree. Your script is missing...
    – RudiC
    Commented Feb 13, 2022 at 19:24
  • Or the #! on the first line of your script is funny.
    – waltinator
    Commented Feb 14, 2022 at 0:29

0

You must log in to answer this question.

Browse other questions tagged .