#!/bin/bash
# Concatenate two passwords files. The resulting will contain entries of the first file with UID < 500 and that of second with UID > 500
DATE=`date +%d.%m.%Y`
TIME=`date +%H.%M.%S`
echo Name of File 1
read f1
echo Name of File 2
read f2
echo Name for New file
read newfile
mv $newfile $newfile.bak.$DATE.$TIME
## Manipulate first file
count=`cat $f1 | cut -f3 -d : | sort -n | wc -l`
h=1
while [ "$count" -ge "$h" ]
do
{
id=`head -$h $f1 | tail -1 | cut -f3 -d:`
if [ $id -lt "500" ]
then
{
head -$h $f1 | tail -1 >> $newfile
}
fi
h=$[$h + 1 ]
}
done
## file 2
count=`cat $f2 | cut -f3 -d : | sort -n | wc -l`
count=$(`expr 'cat count'`)
h=1
while [ "$count" -ge "$h" ]
do
{
id=`head -$h $f2 | tail -1 | cut -f3 -d:`
if [ $id -gt "499" ]
then
{
username=`head -$h $f2 | tail -1 | cut -f1 -d:`
grep $username: $newfile
if [ $? = "0" ]
then
echo "User $username or *$username* already exists in $newfile came from $f1 with UID less than 500"
else
head -$h $f2 | tail -1 >> $newfile
fi
}
fi
h=$[$h + 1 ]
}
done
Wednesday, October 17, 2007
Subscribe to:
Post Comments (Atom)
AT&T USA | Internet not working | Fix by custom APN
If the AT&T Mobile internet is not working on your cellphone, it can be fixed easily by adding an APN configuration. You can read this a...
-
Hi there, You all know how to check TCP port connectivity from a Linux or UNIX machine to a remote machine using telnet as per th exampl...
-
Before you start Ensure that you have installed wvdial, usbmodeswitch and usbmodeswitch_data # dpkg -l | grep wvdial # dpkg -l | grep ...
-
1. Open Applications -> System -> Configuration Editor from the GUI OR Open a terminal, type gconf-editor 2. Go to "...
No comments:
Post a Comment