Home > OS >  Shell script using the parameters passed to switch directory
Shell script using the parameters passed to switch directory

Time:09-20

#!/bin/bash
The Model=$1
Fwversion=$2
The RPM=` CD $Model/ExeRpmVib/$Fwversion/swpackages | PWD `
Echo $RPM

[root @ root 20191226] # source update. Sh ST10000NM0096 baseline
- bash:/CD: no the file or directory
/root/20191226
What an absolute path all tried, strives for the big help!

CodePudding user response:

Check your catalog file exists, or whether the wrong file name

CodePudding user response:

Try this

The RPM=` CD ${Model}/ExeRpmVib/${Fwversion}/swpackages `

Echo $RPM

The PWD & gt; PTS/0 (assuming your pseudo terminal is PTS/0, you can use the w oneself check)

You so you can know whether the statement right

CodePudding user response:

#!/bin/bash
The Model=$1
Fwversion=$2
RPM=` CD $Model/ExeRpmVib/$Fwversion/swpackages | PWD ` # here is to use the pipe "|"?
Echo $RPM

Pipe is an instruction on the results as the parameters of the next instruction, obviously it is wrong to you here,
Change:
#!/bin/bash
The Model=$1
Fwversion=$2
The RPM=` CD $Model/ExeRpmVib/$Fwversion/swpackages & amp; & The PWD ` # here is to use the pipe "|"?
Echo $RPM

CodePudding user response:

Try this
The Model=$1
Fwversion=$2
CD $Model/ExeRpmVib/$Fwversion/swpackages & amp; & pwd
  • Related