unix array


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix array
# 1  
Old 03-26-2009
unix array

Hi ,
suppose , i have a array variable with size 40 and i have assign a 10 character values. I want to print the array like ,the 10 caharacter value with rest 30 character as blank, if i assigned any blank values also .it will print 40 blank space.
Please help me regaring this.It is very urgent .

Thanks in advance

Smilie
# 2  
Old 03-26-2009
Look into the command "printf".
# 3  
Old 03-26-2009
it is not working properly .
# 4  
Old 03-26-2009
Show your script inside code tags so we don't have to guess, please.
# 5  
Old 03-26-2009
MySQL

Hi below is the code :
Code:
INFILE="/home2/prax/prac30/c2t/input.txt"
OUTFILE="/home2/prax/prac30/c2t/cage_output.txt"
while read line
do
STCODE=`echo $line | awk -F , '{print $1 }' `
ZIP=`echo $line | awk -F , '{print $2 }' | `
CMKTNM=`echo $line | awk -F , '{print $3 }' `
CMKTCD=`echo $line | awk -F , '{print $4 }'`
CSCTNM=`echo $line | awk -F , '{print $5 }' `
CSCTCD=`echo $line | awk -F , '{print $6 }' `
TLGMKTNM=`echo $line | awk -F , '{print $7 }'`
TLGMKTCD=`echo $line | awk -F , '{print $8 }'`
TLGSMKTNM=`echo $line | awk -F , '{print $9 }'`
TLGSMKTCD=`echo $line | awk -F , '{print $10 }'`
if [ -z $CMKTNM ]
then
echo $line | awk -F , '{printf $1 $2 $7 $8 }'
fi
done < ${INFILE}


Last edited by zaxxon; 03-26-2009 at 07:27 AM.. Reason: I asked for code tags - they are now implemented - maybe check your post in edit-mode to see what I meant
# 6  
Old 03-26-2009
Is there any use of all those variables you fill with values? If not maybe just post a snippet of your input file and an example of the desired output. At first glance there is a lot which might be easily simplified.
Use code tags like I implemented them in your former post. Check your old post in edit-mode so you see what I mean.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Array V-Lookup using UNIX bash

Hey everyone, I am trying to extract column values from a column in a tab-delimited text file and overlay them in a 2nd tab-delimited text file using a V-lookup type script in Unix bash. These are the 1st few rows of the 1st input file IN1: rsid chromosome position allele1 ... (10 Replies)
Discussion started by: Geneanalyst
10 Replies

2. Shell Programming and Scripting

storing large data in unix array variable

Hi, I have table in sql ..from this table im storing the first coloumn values in shell array variable ... after this passing this variable as an arugument in SQL procedure. But the proc. is running fine only for 1024 values in array ... How to store more than 1024 values in the array... (5 Replies)
Discussion started by: ankitknit
5 Replies

3. Shell Programming and Scripting

Using unix array in sql

Hi all, I have declared an array in unix as below. #!/bin/ksh arr=() for i in {0..4} do arr=$i; done. i want to insert these array variables into the oracle table.can you guys please help me in doing this. my code is as below. value=`sqlplus -s fos/fos << EOF begin for j in... (10 Replies)
Discussion started by: Mukta
10 Replies

4. Shell Programming and Scripting

Please help on array in unix

how can i assign each line to a variable ? i tried below but its not working. code: arr=cat tes.txt|cut -d "=" -f2 then i tried to see output of the first line by below command but its giving first line. echo $arr Please help me. How i can assing each line to a array? Thank,... (1 Reply)
Discussion started by: prince1987
1 Replies

5. Shell Programming and Scripting

Array in unix

Dear masters, Need your help for my below query. Actually my script is as shown: #!/usr/bin/ksh pp='"aa bb" cc dd' set -A mon -- $pp echo ${mon} echo ${mon} echo ${mon} But when I execute this script , I get the output as : "aa bb" cc I want the output as below and it should... (6 Replies)
Discussion started by: patric2326
6 Replies

6. Shell Programming and Scripting

How to display two dimensional array in UNIX

Hi all, Please help me out how to read and display two dimensional array elements in unix. EX: 1 2 3 4 (1 Reply)
Discussion started by: eswarcs
1 Replies

7. Shell Programming and Scripting

2 dimensional array in unix

I am trying to implementing two dimensinal array in ksh script.Would you pls help me out. I have a large size of file, File contains looks like ID SID VLAUE1 VALUE2 TOTALVALUE 1 a1 01 02 03 1 b1 02 05 07 ... (2 Replies)
Discussion started by: pritish.sas
2 Replies

8. Shell Programming and Scripting

Reading Of Array Element in Unix

Hi, I am using the following command to initialize and array # arr=ffffff00 # echo $arr ffffff00 my requirement is i want to fetch the one by one character from array. I don't know how to fetch one by one charcter from array. Please i need an help. Thank you very much Ravi R N (2 Replies)
Discussion started by: ravi_rn
2 Replies

9. Shell Programming and Scripting

Unix Korn Shell Array Issue (SunOS)

Hello, I'm currently messing around with arrays for the first time in scripting (Unix Korn Shell). All I'm trying to do right now before I make things complicated is read through and print out to screen whether the read file is or is not a directory. Here is my directory: ls -l total... (5 Replies)
Discussion started by: Janus
5 Replies

10. Shell Programming and Scripting

Unix script array

Unix shell script; How do I create an array and dynamically populate it with values? How do I retrieve from the array? (4 Replies)
Discussion started by: leemjesse
4 Replies
Login or Register to Ask a Question