0

my script is:

#!/bin/sh
if [[ $# -ne 1 ]] ; then
     echo 'Command line arguments are not equal to 1'
     exit 1
else
     NUMBER=$(grep -n "$1" /acct/common/filename | tr -dc '0-9')
     sed -n "$NUMBER"p /acct/common/filename | sed 's/,/ /g | sed "s/$1/ /g"
fi

The command in the else statement works when ran on its own in the script, but whenever I try to run the script the shell outputs

./findName.sh 2: ./findName.sh: [[: not found

Whenever I pass no arguments and then

./findName.sh: 2: ./findName.sh: [[: not found
expected result

Whenever I pass in an argument that should work

I'm not sure what's wrong as I am fairly new to shell scripting, any help would be greatly appreciated, thanks.

Cyrus
  • 84,225
  • 14
  • 89
  • 153
Aidan Rosser
  • 1
  • 1
  • 3
  • 1
    `sh` ([Bourne-shell](https://en.wikipedia.org/wiki/Bourne_shell)) is usally not `bash` ([Bourne-again shell](https://en.wikipedia.org/wiki/Bash_(Unix_shell))). – Cyrus Nov 11 '20 at 21:02
  • 2
    get in the habit of copy/pasting your code into https://shellcheck.net and fixing any issues flagged. Good luck.] – shellter Nov 11 '20 at 21:04

0 Answers0