error in running the shell script
I have written a shell script which replaces the password of a user in File2 if that user is also present in File1.Following are the contents of two files
File 1
palanspu:3aLdJ8mtCEXJI,A/SS:24563:/usr/bin/ksh
rahul:7j6Zm/48.6rs,A/1S:24669:/usr/bin/ksh
File 2
rahul:ydMaodGCHIzxU,A/jN:25100:/usr/bin/ksh
anukul:YX6UQQl6OpSaU,A/US:25112:/usr/bin/ksh
The script is as follows
#!/bin/bash
#creates array of passwords from File1
pass1=`cut -d ":" -f2 first`
cnt=0
if [ -s tmp-sec ] ; then
rm tmp-sec
else
touch tmp-sec
fi
for usr1 in `cut -d ":" -f1 first` ; do
sed -e "/^$usr1:/ s/:.*$/:${pass1[$cnt]}/" sec >> tmp-sec
cnt=$(($cnt+1))
done
After executing the shell script the output is taken in the file tmp-sec. But I get the error as follows and also the contents of tmp-sec file is not as expected
$ sh temp.sh
sed: Function /^palanpsu:/ s/:.*$/:3aLdJ8mtCEXJI,A/SS cannot
be parsed.
$ cat tmp-sec
rahul:
anukul:YX6UQQl6OpSaU,A/US:25112:/usr/bin/ksh
$
Can anyone help?
|