nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Need help with printing arrary in Ksh

This is a discussion on Need help with printing arrary in Ksh within the Shell scripting forums, part of the Development/Scripting category; Hi, I am trying to (echo ls -l $i) but it's not printing if someone can help me....I am trying ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 08-12-2005, 09:40 PM
Junior Member
User
 
Join Date: Aug 2005
Location: NYC
Posts: 5
Rep Power: 0
avcert1998
Default Need help with printing arrary in Ksh

Hi,

I am trying to (echo ls -l $i) but it's not printing if someone can help me....I am trying to ls -l everything in the arrary....Thanks in advance




script:


#/usr/bin/ksh
typeset -i cnt=0

while read line
do
myarray[$cnt]=$line
((cnt = cnt + 1))
done < myfile
for i in ${myarray[*]i}; do
echo `ls -l $i`
done

data file

myfile:

/usr/share/man/sman3ldap
/usr/share/man/sman3xfn
/usr/share/ds5/manual/en/slapd/schema
/usr/share/audio/samples/au
/usr/share/audio/samples
/usr/share/audio
/usr/share/admserv5.1/manual/en/admin/ag/graphics
/usr/share/lib/zoneinfo
/usr/share/man/man1
/usr/share/man/sman3thr
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-13-2005, 12:36 AM
rockdalinux's Avatar
Contributors
User
 
Join Date: May 2005
Location: Bangalore
My distro: RHEL, HP-UX, Solaris, FreeBSD, Ubuntu
Posts: 564
Rep Power: 7
rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough rockdalinux is a jewel in the rough
Default

Hmm

I executed your script and it run without problem. It mean no error in script. Okay lets see if your path #/usr/bin/ksh is correct or not as I'm on Linux rignt now my path is #/bin/ksh Try to add

Code:
set -x
Before typecase command in script to debug script. I hope myfile is in same directory where script is located.
__________________
Rocky Jr.
You may have my body & soul, but you will never touch my pride!

If you have knowledge, let others light their candles at it.

Certified to work on HP-UX / Sun Solaris / RedHat
Reply With Quote
  #3 (permalink)  
Old 08-16-2005, 02:01 PM
Member
User
 
Join Date: Jul 2005
Posts: 85
Rep Power: 0
ricc
Default

Hello avcert,
can u pls let me know, what is your script used for. I am new and want to know what can I use it for.

Rocky,
Even if u can help, pls, I want to know. I will appreciate it if you can disect what each line does. As you know, I am really very new.

Thanks,

rc
Reply With Quote
  #4 (permalink)  
Old 08-18-2005, 02:52 PM
Junior Member
User
 
Join Date: Aug 2005
Location: NYC
Posts: 5
Rep Power: 0
avcert1998
Default

Rocky,

I figured out what is going on. I was getting very large output. The reason is because some of the files in the data file were directories and I did not realize that. I have removed the directories from the data file and it works fine.

Thanks.


The scripts is supposed to read each line from the file "myfile" and do a "ls -l" on each file.....
Reply With Quote
  #5 (permalink)  
Old 08-18-2005, 05:42 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
My distro: Any distro with shell
Posts: 919
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Always check script/program on different set of input.
__________________
Vivek | My personal blog
Linux Evangelist
Play hard stay cool
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
printing file in perl chandanperl Coding in General 3 04-16-2008 11:03 AM
Cups is not printing text file with proper format, staircasing issue Ashish Pathak CentOS / RHEL / Fedora 1 11-18-2007 08:12 AM
Linux java apps: printing mike herdman Linux software 7 01-15-2007 01:06 PM


All times are GMT +5.5. The time now is 10:58 PM.


Powered by vBulletin® Version 3.7.3 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

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 27 28 29 30 31 32 33 34 35 36