Sponsored Content
Top Forums Shell Programming and Scripting Unix Korn Shell Array Issue (SunOS) Post 302096938 by Janus on Monday 20th of November 2006 07:28:57 PM
Old 11-20-2006
Half of this figured out, made the following corrections toying around with it:

Where I have the bolded piece of the script, replace that with:

if [ $"{filelist[$i]}" = "d" ]

As you can see, the " " are now added in the correct spot.

The results now show the following:

./echodir
echodir
Not A Directory
local.cshrc
Not A Directory
local.cshrc.JASS.20050613104129
Not A Directory
local.login
Not A Directory
local.login.JASS.20050613104129
Not A Directory
local.profile
Not A Directory
local.profile.JASS.20050613104129
Not A Directory
scripts
Not A Directory

Not A Directory

Not A Directory


The errors are gone, but now I'm getting an extra 3 runs of the loop, working on debugging this but wanted to keep you all up to date on how to fix that sort of issue...

Edit: The commands I run within the script to set up the arrays are the following, each file should have it's corresponding identifier as to whether its a file or directory etc. With the results above, it looks like "d" isn't detected at all...

ls -l . | grep -v total | awk '{print $9}'
echodir
local.cshrc
local.cshrc.JASS.20050613104129
local.login
local.login.JASS.20050613104129
local.profile
local.profile.JASS.20050613104129
scripts

ls -l . | grep -v total | awk '{print $1}' | cut -c1
-
-
-
-
-
-
-
d

Last edited by Janus; 11-20-2006 at 08:40 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Oracle To Korn Shell Array

I'm attempting to populate an array in ksh using the following command: set -A $(SELECT_INVOICE | sed '/^$/d') SELECT_INVOICE is a function that executes the SQL query. Problem: Some of the invoice numbers have alpha characters with spaces(example: OVEN MICRO). The Korn shell is treating... (1 Reply)
Discussion started by: kdst
1 Replies

2. Shell Programming and Scripting

korn shell array?

I read it is possible to provide values for an array with the -A option to the read statement; however, I have not been able to get this to work. When I execute a script with the -A option to the read statement, the shell complains that it is an illegal option. If this works, can someone provide... (5 Replies)
Discussion started by: cstovall
5 Replies

3. Shell Programming and Scripting

I can't decalar an array in my korn shell script

I have a script that contains #!/usr/bin/ksh set -A X 'hallo' 'world' echo ${X} echo ${X} when I execute it I get an errror message sh ./test.ksh ./test.ksh: -A: bad option(s) but if I do this at the command prompt I am able to create it set -A myarray '1' '2' '3' echo ${myarray}... (4 Replies)
Discussion started by: zilla30066
4 Replies

4. Shell Programming and Scripting

Could someone give me an example of awk accessing array defined in Korn Shell?

As per title and much apprecieated! (2 Replies)
Discussion started by: biglau
2 Replies

5. Shell Programming and Scripting

korn shell .kshrc in sunos

Hi, My login shell is c shell I have a line in .cshrc like setenv a 1000 I have a line in .profile like ENV=$HOME/.kshrc export ENV and in my .kshrc a=10 export a I wrote one korn script #!/bin/ksh echo $a (3 Replies)
Discussion started by: shahnazurs
3 Replies

6. Shell Programming and Scripting

need help with korn shell array

I have a korn shell script that reads a file with just one column in the file. If the file has more than 5 entries it is split using split -5. This means that is we have 15 entries I will end up with 3 files with 5 entries/lines in each and if I have 23 entries I will end up with 5 files with the... (2 Replies)
Discussion started by: kieranfoley
2 Replies

7. Shell Programming and Scripting

Generate array name at run time Korn shell

Hi, I am trying to define number of array based on constant derived during execution phase of a script. Here is what i am trying.. #First Part, Get LUN input from User lun_count=4 count=0 set -A my_lun while : do while ]; do read L?"Enter Lun "$count" Number:" ... (2 Replies)
Discussion started by: harris2107
2 Replies

8. Shell Programming and Scripting

Korn Shell Array maximum value less than other value

I have a text file with several key words that I am trying to isolate. I have grepped for the unknowns in the text file, but each unknown has a corresponding location. I have created an array that holds all the unknowns and another array that holds all of the locations and compares them based on... (12 Replies)
Discussion started by: ther2000
12 Replies

9. Shell Programming and Scripting

'*' vs. '@' in Korn Shell Array Variables

In order to use the shellcurses functions described at: Shell Curses function library I am learning about ksh, which has arrays. My trusty Kochan & Wood book says that for any Korn Shell array AR : ${AR } expands to all the defined array elements, and ${#AR } expands to the number... (3 Replies)
Discussion started by: Clovis_Sangrail
3 Replies

10. Shell Programming and Scripting

How to append to array within conditional block in ksh/korn shell?

Hi, I have one array created and some values are there in ksh. I want to append some other values to it based on some condition in if statement. #!/bin/ksh echo "---------------------------------------------------" set -A ipaddr_arr $(egrep -v '^#|^::|^$' /etc/hosts |awk '{print $1}'... (2 Replies)
Discussion started by: sanzee007
2 Replies
hier(7) 						 Miscellaneous Information Manual						   hier(7)

Name
       hier - file system hierarchy

Description
       The following is a brief description of the root file system.  The major directory hierarchy and representative files are listed.

       Symbolic links can be included in the files to provide backward compatibility. To display the links, type:
       % ls -l

       See the Guide to Disk Maintenance for more detailed information.

       /       Directory  for  root file system. This file system is separated into nonsharable data, (root (/)) and sharable data, (/usr).  These
	       two file systems are each divided into the following types: static data, variable data, and executable data.

       /bin    Directory for the single user executable data files.

       /bin/init
	       Parent of all processes,

       /bin/mount
	       Mount program,

       /dev    Directory for devices.
		  MAKEDEV Shell script to create special files
		  MAKEDEV.local
			  Site-specific part of MAKEDEV
		  console Main console,
		  rz	  SCSI disks,
		  rrz*	  Raw SCSI disks,
		  rmt*	  Tapes
		  mrmt*   Tapes
		  tty*	  Terminals,
		       .
		       .
		       .

       /etc    Directory for the machine-specific static data files and shell scripts for booting.
		  crontab   System clock daemon table,
		  disktab   Disk characteristics and partition tables,
		  fstab     File system configuration table,
		  group     Group file,
		  hosts     Host name-to-network address mapping file,
		  motd	    Message-of-the-day file,
		  networks  Network name-to-network number mapping file,
		  passwd    Password file,
		  protocols Name-to-number mapping file,
		  rc	    Shell script to bring the system to multiuser mode
		  rc.local  Site-dependent portion of rc
		  remote    Names and description of remote hosts for and
		  services  Network services definition file,
		  termcap   Description of terminal capabilities,
		  ttys	    Properties of terminals,
		       .
		       .
		       .

       /lib    Symbolic link to

       /lost+found
	       Directory for connecting detached files for

       /sys    Symbolic link, normally to

       /tmp    Directory for temporary files (see also
		  e*	 Used by
		  ctm*	 Used by
		       .
		       .
		       .

       /usr    General purpose directory, on which the file system is normally mounted (see description that follows).

       /var    Directory for variable length files, such as spool, administrative, and temporary files. These files can also be located in See the
	       Guide to Disk Maintenance.

       /vmunix Kernel image

       The  directory contains the sharable data. The following is a brief description of the file system.  The major directory hierarchy and rep-
       resentative files are listed.

       /usr	 Root directory for file system.

       /usr/adm  Directory for administrative information, which is now a symbolic link to
		    crash   Directory for crash dumps
		    vmcore.?,vmunix.?	Crash dump files
		    lpacct  Line printer accounting,
		    tracct  Phototypesetter accounting,
		    wtmp    Login history,
			 .
			 .
			 .

       /usr/bin  Directory for the shared executable data files, including utility programs and Shell scripts.
		    as	 assembler
		    cc	 C compiler executive (see also and
		    csh  C shell
			 .
			 .
			 .

       /usr/dict Directory for word lists.
		    spellhist History file,
		    words     Word list,
			 .
			 .
			 .

       /usr/doc  Directories containing files for the Vol.2 documentation.
		    as	 Assembler manual
		    c	 C manual
			 .
			 .
			 .

       /usr/etc  Directory for utility programs and shell scripts.

       /usr/etc/cron
		 Clock daemon,

       /usr/etc/dump
		 Dump program,

       /usr/examples
		 A directory where components of the base system and Digital's separately licensed products can locate code examples, scripts, and
		 demos for customers to use.  A typical use is to complement printed documentation.

       /usr/games
		 Directory for games.
		    hangman   Hangman game
		    lib       Library directory for games
			 .
			 .
			 .

       /usr/etc/getty
		 Part of login,

       /usr/include
		 Directory for standard #include files.
		    a.out.h  Object file layout,
		    math.h
		    stdio.h  Standard I/O,
		    sys      Symbolic link to (system generation #include files)
			 .
			 .
			 .

       /usr/lib  Directory for the shared static data files, such as object libraries.
		    atrun   System scheduler,
		    cpp     C preprocessor
		    libc.a  System calls and standard I/O (2,3,3S)
		    font    Directory for fonts
		    lint    Directory for utility files for
		    tmac    Directory for macros
		    units   Data file of conversion tables for
		    uucp    Directory for programs and data
			 .
			 .
			 .

       /usr/man  Directory for unformatted and preformatted reference (manual) pages.
		    cat1    Section 1 (preformatted)
		    cat2    Section 2 (preformatted)
		    cat3    Section 3 (preformatted)
			 .
			 .
			 .
		    man1    Section 1 (unformatted)
		    man2    Section 2 (unformatted)
		    man3    Section 3 (unformatted)
			 .
			 .
			 .

       /usr/mdec Directory for ULTRIX boot files.

       /usr/msgs Directory for messages,

       /usr/new  Directory for binaries of new versions of programs.

       /usr/preserve
		 Directory for editor files preserved after crashes or hangups.

       /usr/skel Directory for sample user startup files.
		    .cshrc   Startup file for
		    .login   Login startup file for
		    .mailrc  Startup file for
		    .profile Startup file for
		    .project Lists information used by

       /usr/spool
		 Directory for delayed execution files, which is now a symbolic link to
		    at	 Directory used by
		    lpd  Directory used by
			    lock Present when line printer is active
			    cf*  Copy of file to be printed, if necessary
			    df*  Daemon control file,
			    tf*  Transient control file (exists while is working)
		    mail  Mailboxes for
			    name	Mail file for user name
			    name.lock	Lock file (exists while name is receiving mail)
		    uucp  Work files and staging area for
			    LOGFILE	Summary log

       /usr/src  Generic sources.
		    usr.bin User sources
			      troff and sources
			      term  Directory of description files for new printers

       /usr/sys  Directory for system files.
		    b.mips    BINARY for MIPS
		    b.vax     BINARY for VAX
		    fs	      Filesystem SRC
		    net       Netword SRC
		    mips      MIPS-specific SRC
		    vax       VAX-specific SRC
		    data      System data files
		    conf/{mips,vax}
			      Configuration files
		    h	      #include files
		    SAS       Standalone system
		    sys       Machine independent SRC

       /usr/tmp  Symbolic link to

See Also
       apropos(1), find(1), finger(1), grep(1), ls(1), whatis(1), whereis(1), which(1), ncheck(8)
       Guide to Disk Maintenance

								       RISC								   hier(7)
All times are GMT -4. The time now is 06:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy