Sponsored Content
Full Discussion: Query on scp
Top Forums UNIX for Beginners Questions & Answers Query on scp Post 303001033 by rbatte1 on Tuesday 25th of July 2017 12:44:15 PM
Old 07-25-2017
Ah, I should not have quoted the line array=("${array_val}")

Try is with array=(${array_val}) for the last line instead. Does that help?


You might need to work with line 6 too, perhaps this would be better overall:-
Code:
array_val=""
for filename in *
do
   timestamp=$(stat -c %Y $filename)
   ## Trim the timestamp as required or adjust it to your required format
   array_val="${array_val} ${timestamp},${filename}"
done
array=(${array_val})

for item in 0 1 2 3 4 5
do
   echo "Value for item $item is ${array[$item]}"
done


The date/time value is in seconds from the Epoch, else the array would split up. is that a problem? We can work on fixing it if we need to.



Robin
 

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

What is scp-ed over?

Hi all, i have a directory in server A. the directory path is /home/kevin. I need to scp the directory to another server B. i would like to ask, when i do a scp of the /home/kevin , i can expect all the files from A to go B. However, how about the hidden files? for example the ssh keys in the... (4 Replies)
Discussion started by: new2ss
4 Replies

2. Shell Programming and Scripting

scp

hi can any one pls tell me how to copy a file from a remote host to the same remote host with a timestamp, i need to use only scp. thnks (4 Replies)
Discussion started by: bkan77
4 Replies

3. Shell Programming and Scripting

Query related to scp command

Hi Friends, I need to execute a scp command to transfer some files from source to target server. Unfortunately the ftp is not working in my case. This scp command needs to be executed via Unix script. I need to know the complete scp command which includes the user-id and password of the... (2 Replies)
Discussion started by: sureshg_sampat
2 Replies

4. Shell Programming and Scripting

Is this possible with SCP?

I normally download a directory recursively using: scp -r <name>@host:<path> . This has worked fine. As everyone knows this will download all of the directory named in <path> and all of the sub directories. I would like to know if it is possible to not download a particular file if it... (5 Replies)
Discussion started by: cpabrego
5 Replies

5. Shell Programming and Scripting

add the output of a query to a variable to be used in another query

I would like to use the result of a query in another query. How do I redirect/add the output to another variable? $result = odbc_exec($connect, $query); while ($row = odbc_fetch_array($result)) { echo $row,"\n"; } odbc_close($connect); ?> This will output hostnames: host1... (0 Replies)
Discussion started by: hazno
0 Replies

6. Shell Programming and Scripting

Query Oracle tables and return values to shell script that calls the query

Hi, I have a requirement as below which needs to be done viz UNIX shell script (1) I have to connect to an Oracle database (2) Exexute "SELECT field_status from table 1" query on one of the tables. (3) Based on the result that I get from point (2), I have to update another table in the... (6 Replies)
Discussion started by: balaeswari
6 Replies

7. Shell Programming and Scripting

Shell Script to execute Oracle query taking input from a file to form query

Hi, I need to query Oracle database for 100 users. I have these 100 users in a file. I need a shell script which would read this User file (one user at a time) & query database. For instance: USER CITY --------- ---------- A CITY_A B CITY_B C ... (2 Replies)
Discussion started by: DevendraG
2 Replies

8. UNIX for Dummies Questions & Answers

How to use scp?

How to copy multiple directories using single command on solaris 10 from server A to server B. I tried scp but its working only one directory at atime How to acheive this with simple and short solution????? (6 Replies)
Discussion started by: buzzme
6 Replies
ARRAY_REDUCE(3) 							 1							   ARRAY_REDUCE(3)

array_reduce - Iteratively reduce the array to a single value using a callback function

SYNOPSIS
mixed array_reduce NULL (array $array, callable $callback, [mixed $initial]) DESCRIPTION
array_reduce(3) applies iteratively the $callback function to the elements of the $array, so as to reduce the array to a single value. PARAMETERS
o $array - The input array. o $callback - mixed callback (mixed $carry, mixed $item) o $carry - Holds the return value of the previous iteration; in the case of the first iteration it instead holds the value of $ini- tial. o $item - Holds the value of the current iteration. o $initial - If the optional $initial is available, it will be used at the beginning of the process, or as a final result in case the array is empty. RETURN VALUES
Returns the resulting value. If the array is empty and $initial is not passed, array_reduce(3) returns NULL. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | Changed $initial to allow mixed, previously | | | integer. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 array_reduce(3) example <?php function sum($carry, $item) { $carry += $item; return $carry; } function multiplication($carry, $item) { $carry *= $item; return $carry; } $a = array(1, 2, 3, 4, 5); $x = array(); var_dump(array_reduce($a, "sum")); // int(15) var_dump(array_reduce($a, "multiplication", 10)); // int(1200), because: 10*1*2*3*4*5 var_dump(array_reduce($x, "sum", "No data to reduce")); // string(17) "No data to reduce" ?> SEE ALSO
array_filter(3), array_map(3), array_unique(3), array_count_values(3). PHP Documentation Group ARRAY_REDUCE(3)
All times are GMT -4. The time now is 05:24 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy