0

f1.sh

dweb=$1
web=$2

wget \
      --recursive \
      --no-clobber \
      --page-requisites \
      --html-extension \
      --convert-links \
      --restrict-file-names=windows \
      --domain $dweb \
      --no-parent \
         $web

f2.sh

web=$1

wget \
      --recursive \
      --no-clobber \
      --page-requisites \
      --html-extension \
      --convert-links \
      --restrict-file-names=windows \
      --no-parent \
         $web

I combine them in a new mynewfunc.sh file but it doesn't seem to work. f1.sh takes two args f2.sh takes one arg. How do I combine them using mynewfunc.sh without getting any errors so I can use one or two args using one .sh file.

genggi
  • 1
  • 1
  • just call them from another script: `sh /f1.sh; sh /f2.sh` – BSP Nov 25 '21 at 10:44
  • 3
    This is a repost of your earlier question: [how to combine two bash script function to a single sript](https://stackoverflow.com/questions/70092952/how-to-combine-two-bash-script-function-to-a-single-sript). – Gino Mempin Nov 25 '21 at 13:49

1 Answers1

1

I believe what you are looking for is $# (the amount of parameters of a bash script). When this equals 1, you launch your first script. Otherwise you launch your second one. More information can be found in this other StackOverflow post.

Dominique
  • 16,450
  • 15
  • 56
  • 112