Typeset is not working in Linux korn shell scripting


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Typeset is not working in Linux korn shell scripting
# 1  
Old 05-29-2017
Typeset is not working in Linux korn shell scripting

Hi All,

Kindly help on the below issue ASAP. Its very urgent.

I have script in which we have below two lines for code and it is not working. Please help.

Code:
files_to_process="
abc_*.log
def_*.log
ghi_*.log
"

typeset -A dir_list ${files_to_process}

the script is failing in Linux korn shell with below error.

Code:
-ksh: typeset: abc_*.log: invalid variable name

Thanks in Advance.


Moderator's Comments:
Mod Comment Please use CODE tags as required by forum rules!

Last edited by RudiC; 05-29-2017 at 02:38 AM.. Reason: Added CODE tags.
# 2  
Old 05-29-2017
Please be aware that statements like "ASAP" and "very urgent" are highly deprecated in these fora.

Everyone at the UNIX and Linux Forums gives their best effort to reply to all questions in a timely manner. For this reason, posting questions with subjects like "Urgent!" or "Emergency" and demanding a fast reply are not permitted in the regular forums.

For members who want a higher visibility to their questions, we suggest you post in the Emergency UNIX and Linux Support Forum. This forum is given a higher priority than our regular forums.

Posting a new question in the Emergency UNIX and Linux Support Forum requires forum Bits. We monitor this forum to help people with emergencies, but we do not not guarantee response time or best answers. However, we will treat your post with a higher priority and give our best efforts to help you.

If you have posted a question in the regular forum with a subject "Urgent" "Emergency" or similar idea, we will, more-than-likely, close your thread and post this reply, redirecting you to the proper forum.

Of course, you can always post a descriptive subject text, remove words like "Urgent" etc. (from your subject and post) and post in the regular forums at any time.


Thank you.

The UNIX and Linux Forums
# 3  
Old 05-29-2017
It's not clear what you want to achieve with your failing command. Is it an associative array with the file names as indexes? As element values?
# 4  
Old 05-30-2017
In addition to what RudiC has already said, if you are trying to create an associative array with filenames as the indexes in your arrray, you need to also specify that values that are to be assigned to those elements in the array. For example:
Code:
typeset -A dir_list=([abc_123.log]=6 [abc_234.log]=29 [def_357.log]="a string" ["ghi_12()x.log"]="something else")

If you just wanted an indexed array where the filenames are the values of elements with indexes 0 through 3 (assuming the same four file matching your patterns exist in the directory in which you run your script, then just try:
Code:
dir_list=(abc_*.log def_*.log ghi_*.log)

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

While within while is not working in Korn shell

Hi all, I tried to execute a while within another while, but not working. Any suggestions? Thanks in advance #!/bin/ksh typeset -i i=1 typeset -i j=1 while ] do while ] do print i = $i j= $j (( j=j+1 )) done (( i=i+1)) done (3 Replies)
Discussion started by: Soham
3 Replies

2. Shell Programming and Scripting

Dialog box in korn shell scripting

Does dialog box works on all kind of shells? I am using korn shell in Linux . For me dialog is not working :) is there any particular syntax or do we need to have particular OS version or shell env? #!/bin/ksh dialog --title "create file" \ --backtitle "shell script practice" \... (1 Reply)
Discussion started by: NarayanaPrakash
1 Replies

3. Shell Programming and Scripting

Help needed in Korn Shell scripting

#! /bin/ksh while read line do if ] ; then echo "no data" continue; fi echo "performing operation on $line" done < prg.txt (3 Replies)
Discussion started by: Juhi Kashyap
3 Replies

4. Shell Programming and Scripting

Help when using Typeset in AIX Korn Shell

Guys, please help! I am currently using an AIX server however whenever I tried to use the typeset -F3, the variable is resulting with a "#". In the given example below, I declared x to be a decimal holding 3 decimal places = 1.455. However whenever I tried to echo the $x, the resulting value... (9 Replies)
Discussion started by: zzavilz
9 Replies

5. Homework & Coursework Questions

korn shell scripting

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: There is a menu driven program and there are some fields to be achived 3. Display contents of all .lst files... (3 Replies)
Discussion started by: jainitai
3 Replies

6. UNIX for Advanced & Expert Users

Comparison in Korn shell scripting

I have a scenario to implement in Korn shell script. Here it is.. I need to compare two values to see whether they are same or not. The issue is that the values coming in for comparison can be a string or an integer which can be determined during run time only. Which korn shell comparison... (2 Replies)
Discussion started by: vani123
2 Replies

7. Shell Programming and Scripting

Korn shell scripting

I am attempting to learn shell programming using o'rielly book "Learning the Korn Shell". I am finding it pretty difficult to do since the only access I have to unix boxes are running version 99 of ksh. The book utilizes ksh93 and there appear to be many differences. I can't even follow along... (2 Replies)
Discussion started by: vedder191
2 Replies

8. Shell Programming and Scripting

Solaris Korn Shell Scripting

I have made the following simple script: a=0 let a=$a+1 if "] then mailx -s "Up" abc@yahoo.com fi When I run the above script, I get the following error: # ./new.ksh ./new.ksh: ]: not found. Please tell me how to use if here? (6 Replies)
Discussion started by: kamaldeep1986
6 Replies

9. UNIX for Dummies Questions & Answers

Help with Korn Shell Scripting

Hi I'm new to scripting and I don't know where to start. I need to create a script that needs to look for specific files in a specific folder then I need to return the filename, the recordcount, bytecount and checksums. Then I need to write these results into a new file. I would appreciate... (2 Replies)
Discussion started by: th0123
2 Replies

10. Shell Programming and Scripting

Repost-Korn Shell Scripting

Hi, being very new to Korn Shell Scripting I am hoping that someone here can help me. I want to compare file name in scp/inbox directory to file name stored inside a file in pnt/compare directory. Hi, being very new to Korn Shell Scripting I am hoping that someone here can help me. I want to... (1 Reply)
Discussion started by: hanie123
1 Replies
Login or Register to Ask a Question