Hi,
I'm sure that I'm making this harder than it really is and would appreciate any help.
I have written a script that reports the size of home directories and compares the information to previously collected data.
I am using awk to find the user in a list containing the directory size and the users name:
11096 admin
23456 bsmith
27869 jhart
223 bak-admin
7789 kbasmith
So, when I grep (/usr/bin/grep on Solaris 8) for admin I get the output for both bak-admin and admin.
This isn't the actual list of users (directories) but represents our naming convention for user home directories.
Below is an example of what I am doing in my script and what I am getting as out put:
#!/bin/sh
oldlist=list.old
user=`awk '{ print $2 }' $oldlist`
echo $user
oldsize=`for i in $user
do
grep "\<$i\>" $oldlist | awk '{ print \$1 }'
done`
echo $oldsize
The contents list.old is:
11096 admin
23456 bsmith
27869 jhart
223 bak-admin
7789 kbasmith
Running the script results in following output:
admin bsmith jhart bak-admin kbasmith lost+found
11096 223 23456 27869 223 7789 2234
As you can see the script is reporting the "$oldsize" for admin is reported as 11096 and 223.
This is wrong and causes problems with the rest of my script.
I have also tried /usr/xpg4/bin/grep -E and /usr/xpg4/bin/grep -F -x but neither are the correct solution.
Thanks in advance.
-Joe
I'm sure that I'm making this harder than it really is and would appreciate any help.
I have written a script that reports the size of home directories and compares the information to previously collected data.
I am using awk to find the user in a list containing the directory size and the users name:
11096 admin
23456 bsmith
27869 jhart
223 bak-admin
7789 kbasmith
So, when I grep (/usr/bin/grep on Solaris 8) for admin I get the output for both bak-admin and admin.
This isn't the actual list of users (directories) but represents our naming convention for user home directories.
Below is an example of what I am doing in my script and what I am getting as out put:
#!/bin/sh
oldlist=list.old
user=`awk '{ print $2 }' $oldlist`
echo $user
oldsize=`for i in $user
do
grep "\<$i\>" $oldlist | awk '{ print \$1 }'
done`
echo $oldsize
The contents list.old is:
11096 admin
23456 bsmith
27869 jhart
223 bak-admin
7789 kbasmith
Running the script results in following output:
admin bsmith jhart bak-admin kbasmith lost+found
11096 223 23456 27869 223 7789 2234
As you can see the script is reporting the "$oldsize" for admin is reported as 11096 and 223.
This is wrong and causes problems with the rest of my script.
I have also tried /usr/xpg4/bin/grep -E and /usr/xpg4/bin/grep -F -x but neither are the correct solution.
Thanks in advance.
-Joe