Visit Our UNIX and Linux User Community


How to group the output w/ limit


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to group the output w/ limit
# 1  
Old 07-23-2009
Question How to group the output w/ limit

Hi All,

Second time to post on this group Smilie

I'm pulling my hair now 'coz I'm so dumb to produce this requirement.

Requirement: I want to run a utility by limiting the no. inside my process (mov##) to be able to use in multi streaming.

Here is my script:
--Input: "user_list.txt"
40013163:5
40109925:3
89877423:4
73084042:1
40152547:2
82475674:0

--Script:
Code:
set -A ext_ids `cat user_list.txt`

process_id=2
total_extid=${#ext_ids[@]}
cnt=0
while [ $cnt -lt $total_extid ]
  do
    if [ $total_extid -lt 6 ]
    then
     echo "PREQ_MOVER mov0$process_id ${ext_ids[$cnt]} "
    else
     # Always starts w/ process_id 2
     process_id=`expr 2 + $cnt / 3` # Increase the dividend to increase the process_id value
      if [ $process_id -le 9 ]
       then
          processid="0$process_id"
      else
          processid=$process_id
      fi
       extids=`echo "${ext_ids[$cnt]}"|cut -d : -f 1`
    echo "PREQ_MOVER mov$processid $extids "
       count=`echo "${ext_ids[$cnt]}"|cut -d : -f 2`
   ## Un/Comment here
        #if [ $count -eq 0 ]
        # then
        #   count=$(($count + 1))
        #fi
    fi
   ## Un/Comment here 
  #cnt=$(($cnt + $count))
  cnt=$(($cnt + 1))
done
# Single stream or multi stream
if [ $total_extid -lt 6 ]
  then
   echo "\n\tRunning Single Stream of MOVER\n"
   echo "MOVER mov0$process_id SOURCE_DB"
  else
   echo "\n\tRunning Multiple Stream of MOVER\n"
   proc=2
    while [ $proc -le $process_id ]
     do
      if [ $proc -le 9 ]
       then
          procs="0$proc"
      else
          procs=$proc
      fi
      echo "MOVER mov${procs} "
      proc=$(($proc + 1))
    done
fi

Output:
PREQ_MOVER mov02 40013163
PREQ_MOVER mov02 40109925
PREQ_MOVER mov02 89877423
PREQ_MOVER mov03 73084042
PREQ_MOVER mov03 40152547
PREQ_MOVER mov03 82475674

Running Multiple Stream of MOVER

MOVER mov02
MOVER mov03

Now by editing the script by uncommenting the commented fields. I get...
Output:
PREQ_MOVER mov02 40013163
PREQ_MOVER mov03 82475674

Running Multiple Stream of MOVER

MOVER mov02
MOVER mov03
Note: The output above skips from 40013163 to 40013163 & the rest are not shown. Smilie

Desired Output: (limit to 3 accounts inside each mov## process)
PREQ_MOVER mov02 40013163 -> since it has 5, it will take up the whole process "mov02". This will fill up the process even if it exceeds the limit
PREQ_MOVER mov03 40109925 -> will take mov03 as it has 3
PREQ_MOVER mov04 89877423 -> will take mov04 as it has 4. This will fill up the process even if it exceeds the limit.
PREQ_MOVER mov05 73084042 -> has 1, will use mov05 since the limit is not met
PREQ_MOVER mov05 40152547 -> has 2, will still use mov05 to fill up the limit
PREQ_MOVER mov06 82475674 -> this will use mov06 as mov05 is already filled up.

Running Multiple Stream of MOVER

MOVER mov02
MOVER mov03
MOVER mov04
MOVER mov05
MOVER mov06

Question: How to be able to display the desired output in order to limit the nos of each mov## process (even it exceeds) in sequence (no skipping).

Purpose: To run the utility MOVER in multiple stream by not skipping a user in the list.

I hope the explanation above is sufficient & I hope someone will enlighten me on this.

Hoping for your kind assistant. Smilie

Thanx

Previous Thread | Next Thread
Test Your Knowledge in Computers #114
Difficulty: Easy
Linux was derived from the Unix design philosophy.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Limit the number of characters in bash output

Hi, I need some help with this: I'm making a script which does a couple of things with image files. The script is supposed to echo the number of each image it is processing like this: Processing image1.jpgThe problem is with images with very long filenames, so I want to know how to limit the... (5 Replies)
Discussion started by: Shadow_Reaper
5 Replies

2. UNIX for Dummies Questions & Answers

Limit the number of characters in a bash output

I have a script that outputs the weather on two lines. If possibly I would like to set a character limit on them Currently it outputs something like but I would like to limit the lines so appends an ellipsis if nescessary: This is the script #! /bin/bash curl -s --connect-timeout... (2 Replies)
Discussion started by: Light_
2 Replies

3. Shell Programming and Scripting

Limit output in awk

Hi All, I want to delimit the output using awk. For eg:: a,b,c,d,e,f abc,def,ghi should change to a|b|c|d|e|f abc|def|ghi Or to put in another way.. OFS will work in the following code if I seperate the values with comma (eg. $1,$2,$3,$4,$5,$6 ). But since the no. of... (3 Replies)
Discussion started by: PRKS
3 Replies

4. Shell Programming and Scripting

How to group the output of a loop

Hi Guys, This is based on my question previously posted. :) I have my shell script like this: #!/usr/bin/sh e_id=`sqlplus -s scott/tiger@DB<<eof SET PAGESIZE 0 FEEDBACK OFF VERIFY OFF HEADING OFF ECHO OFF; select emp_id from employee; quit ... (1 Reply)
Discussion started by: alvingo
1 Replies

5. Shell Programming and Scripting

How to limit output

hello, i'm trying to figure out a way to limit the output from an SQL query that is counting the number of occurances of a value in a field and the problem is when i run this query against a huge file with many unique values the output is pretty huge. Is there a way i can specifically LIMIT the... (2 Replies)
Discussion started by: bobk544
2 Replies

6. Shell Programming and Scripting

awk help required to group output and print a part of group line and original line

Hi, Need awk help to group and print lines to format the output as shown below INPUT FORMAT set echo on set heading on set spool on /* SCHEMA1 */ CREATE TABLE T1; /* SCHEMA1 */ CREATE TABLE T2; /* SCHEMA1 */ CREATE TABLE T3; /* SCHEMA1 */ CREATE TABLE T4; /* SCHEMA1 */ CREATE TABLE T5;... (5 Replies)
Discussion started by: rajan_san
5 Replies

7. Solaris

Group membership limit

On Solaris, a user is limited to being a member of a maximum of 16 groups. Could someone tell me where this limit comes from, i.e. is it NIS, or Solaris, or NFS that is imposing this limit? What is the work-around to remove this limitation? (4 Replies)
Discussion started by: son_t
4 Replies

8. UNIX for Dummies Questions & Answers

How can I better group my output?

I have a script that puts out a list that looks like this: bb1 newyork bb1 pittsburg bb2 seattle bb2 spokane sl1 sacramento I want to seperate the output so that it instead has a space between each group so like this: bb1 newyork bb1 pittsburg bb2 seattle bb2 spokane sl1... (8 Replies)
Discussion started by: llsmr777
8 Replies

9. Shell Programming and Scripting

Is there a way to limit DIFF output

Hello is there a way to limit the number of lines output by the DIFF command? I tried -C 200 ect and -c but it continues to print out the whole huge file. Reason needed is i'm trying to do alot of DIFFs on a long list of files and would like to only get back an indicator which files are... (2 Replies)
Discussion started by: bobk544
2 Replies

10. UNIX for Advanced & Expert Users

group limit

hi, i have in my /etc/group an unix group full. i need to add new user in this group. users need to have the same gid and the same name... is it possible ? can i create a concatenation with an other group or something else ? thx (1 Reply)
Discussion started by: farzolito
1 Replies

Featured Tech Videos