Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Hello all, I'm having a problem with one part of my KSH script. Below is the script and OutPut. What I would like to do next is combine field 1 "example = Accoskypager" with the other Accoskypager but not print the dups.
EXAMPLE of the output I would like to have.
Accoskypager:;albri013 djung mblah fwils mflat paren007
I'm guessing I would use some kind of AWK command, but I have no clue how to.########### SCRIPT ###################
#!/usr/bin/ksh
DIR=$1
rm /hotel/cco/web-docs/$DIR/phone/RotateInfo.txtfor LIST in `ls /hotel/cco/web-docs/$DIR/phone/Numbers/A*`
do
echo $LIST |cut -d'/' -f8 | read RotateName
for GroupName in `grep -l $RotateName /hotel/cco/web-docs/$DIR/phone/*[0-9]`
do
echo $GroupName |cut -d'/' -f7 | read Group
Names=$(cat /hotel/cco/web-docs/$DIR/phone/$Group | grep -v ". /hotel*" | grep -v "echo" | grep -v "#" | grep -v ^[A])INPUT=`echo $Names | #Reading in each line of $Name
awk '{for(w=1;w<=NF;w++)print $w}' | sort` #Sorting each line and removing newline characters.
echo $RotateName':;'$INPUT >> /hotel/cco/web-docs/$DIR/phone/RotateInfo.txt
done
done
sort -uk 1,1 /hotel/cco/web-docs/$DIR/phone/RotateInfo.txt > /hotel/cco/web-docs/$DIR/phone/RotateInfo1.txt
mv RotateInfo1.txt RotateInfo.txt
######### SCRIPT END ######################### OUTPUT ####################
Accoskypager:;albri013 djung mblah
Accoskypager:;djung fwils mflat paren007
Acufssupport1:;adams098 edxxx002 lerla Acufssupport1:;stein076 edxxx002 lerla
Adbasupport1:;cjohn3 gagne010 gstru jrudl Adbasupport1:;cjohn3 gagne010 gstru scarl
############ END OUTPUT ################
############# MY GOAL OUTPUT ###############
Accoskypager:;albri013 djung mblah fwils mflat paren007
Acufssupport1:;adams098 edxxx002 lerla stein076
Adbasupport1:;cjohn3 gagne010 gstru jrudl scarl
################# END #################Any help would be great.
Thanks Jim

Jim,
Below are the problems:
1. Each time $RotateName is being appended. It should be kept in a variable and should be first checked with the first column value of $NAMES instead of directly storing in $INPUT.
2. $INPUT can have the same name on different lines. Before storing the name aliases in a variable, compare it with each of the names in the variable. If it is not found, then append otherwise skip it.
3. Keep on appending until the first column is different for the consecutive lines.
When it is different, repeat steps 1-3 till EOF.Hope it helps

gurubit
Could you give me an example how I would do this? I'm still really new at scripting.
Thanks a lot for reading my post
Jim

It seems that it is related to another question that you posted before this available at http://www.computing.net/unix/wwwboard/forum/6744.html .
I have posted the script there.
Check and let me know if it helps.If it is not the same as that one, then I would like to have the original file contents which you are formatting, so that I can work with the exact file.

gurubit
Thanks for all the help, sorry I never checked back to my other post. I was really talking about two different problems but the reply to the other post really helped I did a couple of things different put you post helped my a lot.
Jim

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |