-1

echo $dir #prints chia-blockchain/
echo $dir | sed -e s,-blockchain/,, # prints chia
forkname = `$dir | sed -e s,-blockchain/,,`# not working

For some reason last line gives me this error : ./newfork.sh: line 15: chia-blockchain/: Is a directory ./newfork.sh: line 15: forkname: command not found

funnyguy
  • 13
  • 5
  • 3
    Get rid of the spaces in `forkname = $(dir ...)` (and use the more robust `$( ... )` notation instead of backticks – tink Oct 24 '21 at 18:43
  • 3
    Please add a suitable shebang (`#!/bin/bash`) and then paste your script at http://www.shellcheck.net/ and try to implement the recommendations made there. – Cyrus Oct 24 '21 at 18:51
  • 1
    You don't need `sed`, either. `forkname=${dir%-blockchain}` will do what you want. – chepner Oct 24 '21 at 18:52

1 Answers1

1

First, doing forkname = ... make the shell believe you are trying to execute a command called forkname. It should be forkname=.... You second problem is that you have $dir | sed..., you have missed out the echo, echo $dir | sed..., in that it is trying to execute whatever is in $dir.

Bib
  • 922
  • 1
  • 5
  • 10