array variables


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting array variables
# 8  
Old 06-14-2011
This should do what you want.

Code:
 
ls | perl -00 -lane 'BEGIN{$,=","}END{print map {qq|\x27$_\x27|} @F;}'

# 9  
Old 06-15-2011
Hi,

can u please explain the below line :

print map {qq|\x27$_\x27|} @F;
# 10  
Old 06-15-2011
27 is the hexcode for ' (single quote) charecter. Since you wanted your output to be wrapped inside it, added that piece of code to map it.
# 11  
Old 06-15-2011
Hi,

xtremly sorry .. I am not getting the solution mention by you

but want to insert the file names as shown below in bold:

CREATE TABLE PROD_BKP
(
Column1 NUMBER(20),
Column2 VARCHAR2(25),
Column3 NUMBER(1),
Column4 NUMBER(10),
Column5 NUMBER(10)
)
ORGANIZATION EXTERNAL
( TYPE ORACLE_LOADER
DEFAULT DIRECTORY EXTRACT_DIR
ACCESS PARAMETERS
( RECORDS DELIMITED BY NEWLINE
FIELDS TERMINATED BY '|'
MISSING FIELD VALUES ARE NULL
)
LOCATION (EXTRACT_DIR:'prod_bkp_140611_13_30_05.txt','prod_bkp_140611_14_30_05.txt','prod_bkp_140611_15_30_05.t xt','prod_bkp_140611_16_30_05.txt')
)
REJECT LIMIT UNLIMITED
PARALLEL ( DEGREE 5 INSTANCES 1 )
NOMONITORING;
# 12  
Old 06-15-2011
my @Array = <*.txt>;

print "EXTRACT_DIR:'".join("','", @Array)."'";

This can be solve your problem.
# 13  
Old 06-15-2011
Code:
ls | perl -00 -lane 'BEGIN{$,=","}END{print map {qq|\x27$_\x27|} @F;}'

Consider this as the output of your ls command

Code:
 
File1
File2

This will get stored in @F array like below.

Code:
 
$F[0] = File1
$F[1] = File2

Since you wanted the output separted by comma $, (output separtor in perl) is set as -.

But if you try to print the @F now you'll get an output like this without the single quotes

Code:
File1,File2

Since you wanted every item of array @F to be wrapped in single quotes below statement is added before print.

Code:
 
print map {qq|\x27$_\x27|} @F

This is same as writing

Code:
 
print map {"\x27$_\x27"} @F

Map function wraps the array contents inside a single quote. (x27 is hex code equivalent of ' ).
# 14  
Old 06-16-2011
Hi,

Instead of 'print' I want the values of @F to be used/added as below in the command:

LOCATION (EXTRACT_DIR:'prod_bkp_140611_13_30_05.txt','prod_bkp_140611_14_30_05.txt','prod_bkp_140611_15_30_05.t xt','prod_bkp_140611_16_30_05.txt')

I tried as below but not working:

LOCATION (EXTRACT_DIR:map {"\x27$_\x27"} @files)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

For loop; how to construct a array with variables

Hi everybody!! Here is the thing; I have a trouble in this simple situation, I'm trying to write an array with all the arguments of a command. I mean, if I have: ./mycommand.sh aa bb cc dd I need to take an array like this: myarray=(aa bb cc dd) So I use a simple for loop like this: for... (4 Replies)
Discussion started by: andresgom
4 Replies

2. Shell Programming and Scripting

how to use array variables in shell

Hi, everyone. I wrote a code like this for f in HB021* do program done for f in HB034* do program done for f in HB056* do program done . . (5 Replies)
Discussion started by: xshang
5 Replies

3. 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

4. Shell Programming and Scripting

problem in access in array variables

hi all, its me again!!! i've requirement like this: i want to create a file & an array with its name having the filename as its substring. here is the test script!! #!/bin/bash touch $1 declare -a $1_rec; echo -n "$1_rec: " read $1_rec; echo $]; now see output: this is when i enter... (7 Replies)
Discussion started by: tprayush
7 Replies

5. Shell Programming and Scripting

comparing variables in awk array

Hi, I am trying to sort and display the below(like) input using awk command: Input: ------ 0;A 4;A 5;A 33;A 45;A 0;B 4;B 5;B 33;B 45;B Output (desired): (5 Replies)
Discussion started by: pvamsikr
5 Replies

6. UNIX for Dummies Questions & Answers

trying to store variables in an array

im looping through an array setting three variables each time (one of the variables gives me the position in the array and is incremented each loop) im trying to then set the variables to that position in the array without much luck. any ideas? anArray=`$VAR1+$VAR2+"("$pos")"` (1 Reply)
Discussion started by: magnia
1 Replies

7. Shell Programming and Scripting

How to use variables/array in grep command

Hi, I have a reqmt as i have some values in array and I want to search each value in a file by grep command. Here goes my scripting: #!/bin/ksh set -A ArrayA CENTER LEFT RIGHT echo "ArrayA contains: ${ArrayAİ*¨}" grep -e "${ArrayAİ*¨}" filename.txt The above grep is working for... (4 Replies)
Discussion started by: prashant43
4 Replies

8. Shell Programming and Scripting

storing variables in array.Please help

Hi All, I need some help with arrays. I need to take input from the user for hostname, username and password until he enters .(dot) or any other character and store the values in the variable array. I would further connect to the hostname using username and passwd and copy files from server to... (7 Replies)
Discussion started by: nua7
7 Replies

9. Shell Programming and Scripting

Getting variables into a array.

Hi , Im trying to monitor 2 instancesof a process on our solaris server and trying to do a notification if the returned process size is greater than 500M. Since there are two variables returned I want to make use of arrays to check each and every variable that is stored. the issue that im facing... (2 Replies)
Discussion started by: vivsiv
2 Replies

10. Shell Programming and Scripting

Array variables

hi, how to store array values in unix? and how to access array values? can somebody help? kavitha (2 Replies)
Discussion started by: kavitha
2 Replies
Login or Register to Ask a Question