Sponsored Content
Top Forums Shell Programming and Scripting formating array file output using perl Post 17338 by Jimbo on Wednesday 13th of March 2002 05:40:48 PM
Old 03-13-2002
Well, here's a while command that uses printf to output a unix array, and it closes out the line after every 6th entry:

Code:
#!/bin/ksh

a[1]=this
a[2]=array
a[3]=is
a[4]=holding
a[5]=nine
a[6]=entries
a[7]=right
a[8]=now
a[9]=.

i=1
w=0
while [ "${a[$i]}" ]
do
if [ $w -eq 6 ] ; then
   printf "\n"
   w=0
fi
printf "%-8s" ${a[$i]}
((i=i+1))
((w=w+1))
done

printf "\n"
exit 0

Jimbo
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Formating cal output

Hi Gurus, In my Cal output i want to cut the date of 2nd saturday how tyo achive this. for eg in the below output i need that second saturday 13 to be cut. crypto $ cal January 2007 S M Tu W Th F S 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26... (2 Replies)
Discussion started by: Krrishv
2 Replies

2. Shell Programming and Scripting

formating output

I have a file proc.txt which contains the below one. Content-type: text/html <H2>No query</H2> infodba-marabou:/tmp => export QUERY_STRING="IMAN_server_report=full" infodba-marabou:/tmp => $IMAN_ROOT/web/htdocs/cgi-bin/iman > /tmp/proc.txt infodba-marabou:/tmp => cat proc.txt... (20 Replies)
Discussion started by: Krrishv
20 Replies

3. Shell Programming and Scripting

Output formating

Dear All I am stuck in one problem. Kindly help me. I am taking below mention file as input file and want some op file as mention below. Kindly send me all possible suggestion and query. Thnaks Jaydeep bELOW IS THE INPUT FILE: *** Connected to BSCANGR ***... (1 Reply)
Discussion started by: jaydeep_sadaria
1 Replies

4. Shell Programming and Scripting

file formating in Perl

Hi, I am new to unix , I have a requirement for formating the input file and generate the output file as per the downstream requirement .. My application receiving a text input file having 4 field and my application need to check each field and if some value of a field is blank ..then it need... (1 Reply)
Discussion started by: julirani
1 Replies

5. Shell Programming and Scripting

formating output

Hi all, I want to start a new topic on this matter I have this script, #!perl use strict; use warnings; use Data::Dumper; open my $log, '>', 'log-external.txt' or die "Could not open log: $!"; print $log "Subnet,Static,DHCP,Unused\n"; open my $dump, '>', 'dump.log' or die... (2 Replies)
Discussion started by: richsark
2 Replies

6. Shell Programming and Scripting

Formating output

Hello Team i have a file with following data (as columns). I need implement a syntax like below for altering table ALTER TABLE1 TABLENAME ADD COLUMN COL1 CHAR(5) NOT NULL WITH DEFAULT ADD COLUMN COL2 CHAR(5) .. .. ADD COLUMN COLn CHAR(5) NOT NULL... (1 Reply)
Discussion started by: rocking77
1 Replies

7. Shell Programming and Scripting

Array in Perl - Detect several file to be in one array

Hi everyone I have one question about using array in perl. let say I have several log file in one folder.. example test1.log test2.log test3.log and the list goes on.. how to make an array for this file? It suppose to detect log file in the current directory and all the log file will... (3 Replies)
Discussion started by: sayachop
3 Replies

8. UNIX for Advanced & Expert Users

remove print formating from printer output file

I have a print file taken from the print spooler and I want to delete all the formatting leaving only the text. If you vi the file it shows "\304\304 ...." which translates into a printed line on print output. I need to be able to edit and pass this file to another process Thnaks (10 Replies)
Discussion started by: petercp
10 Replies

9. Shell Programming and Scripting

Formating output in html

Hi Guys, I was searching and landed up something here only. This is the code and I want the formatted html in email but that is not working, anybody knows the reason why? #!/bin/sh set -x DATE=`date -u` # Print beginning of webpage function html_header { cat <<END ... (5 Replies)
Discussion started by: bluemind2005
5 Replies

10. Shell Programming and Scripting

Storing the Linux command output to an array in perl script

Hi I am trying to store the output of a command into an array in perl script. I am able to store but the problem is i am unable to print the array line with one line space. i mean i inserted the \n in loop ...but not getting the result. I have written like this #!/usr/bin/perl @a =... (2 Replies)
Discussion started by: kumar85shiv
2 Replies
ARRAY_COMBINE(3)							 1							  ARRAY_COMBINE(3)

array_combine - Creates an array by using one array for keys and another for its values

SYNOPSIS
array array_combine (array $keys, array $values) DESCRIPTION
Creates an array by using the values from the $keys array as keys and the values from the $values array as the corresponding values. PARAMETERS
o $keys - Array of keys to be used. Illegal values for key will be converted to string. o $values - Array of values to be used RETURN VALUES
Returns the combined array, FALSE if the number of elements for each array isn't equal. ERRORS
/EXCEPTIONS Throws E_WARNING if the number of elements in $keys and $values does not match. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.4.0 | | | | | | | Previous versions issued E_WARNING and returned | | | FALSE for empty arrays. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 A simple array_combine(3) example <?php $a = array('green', 'red', 'yellow'); $b = array('avocado', 'apple', 'banana'); $c = array_combine($a, $b); print_r($c); ?> The above example will output: Array ( [green] => avocado [red] => apple [yellow] => banana ) SEE ALSO
array_merge(3), array_walk(3), array_values(3). PHP Documentation Group ARRAY_COMBINE(3)
All times are GMT -4. The time now is 11:15 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy