Hello Everyone
I am try to write a script that will change all the passwords in the passwd file to the same password. I have the script doing everything it needs until I encounter a password that has a "/" in it the SED substitution command fails because it gets to many slashes.
I can get a command to work at the command line to add a "\" in front of the slash so the command takes it a literal character and not apart of the SED command. Here is the command that works at the command line:
The PW: $1$HaERMTGs$GdCxR1AAHOvqBBOcE7vRL/ (The slash at the end messes up the SED command)
I put the PW in var1
The Command: echo $var1 | sed 's/\//\\\//g'
The new PW string: $1$HaERMTGs$GdCxR1AAHOvqBBOcE7vRL\/
For the script I need the new PW string in a variable I tried this:
sPw=`echo $sPw | sed "s/\//\\\//g"`
but the new string does not contain the "\" character I tried to replace the dbl quote marks with single quote marks in the SED command but then I get an error.
Does anyone know how to get the "\" character to appear in front of the slash in the variable or to get SED to ignore the "\" character in the variable and not think it is apart of the command. Any help would be greatly appreciated. Thank you for any help I can get.
I am try to write a script that will change all the passwords in the passwd file to the same password. I have the script doing everything it needs until I encounter a password that has a "/" in it the SED substitution command fails because it gets to many slashes.
I can get a command to work at the command line to add a "\" in front of the slash so the command takes it a literal character and not apart of the SED command. Here is the command that works at the command line:
The PW: $1$HaERMTGs$GdCxR1AAHOvqBBOcE7vRL/ (The slash at the end messes up the SED command)
I put the PW in var1
The Command: echo $var1 | sed 's/\//\\\//g'
The new PW string: $1$HaERMTGs$GdCxR1AAHOvqBBOcE7vRL\/
For the script I need the new PW string in a variable I tried this:
sPw=`echo $sPw | sed "s/\//\\\//g"`
but the new string does not contain the "\" character I tried to replace the dbl quote marks with single quote marks in the SED command but then I get an error.
Does anyone know how to get the "\" character to appear in front of the slash in the variable or to get SED to ignore the "\" character in the variable and not think it is apart of the command. Any help would be greatly appreciated. Thank you for any help I can get.