![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to use array values after the loop. | Devesh5683 | Shell Programming and Scripting | 1 | 05-13-2008 08:38 PM |
| i cannot give array declaration in shell script | naree | SUN Solaris | 20 | 02-19-2008 03:27 AM |
| awk field declaration?? | tonet | Shell Programming and Scripting | 1 | 09-12-2007 09:23 AM |
| declare, assign variables using array, counter, loop | egkumpe | Shell Programming and Scripting | 3 | 08-09-2004 11:56 AM |
| Variable declaration | laila63 | High Level Programming | 2 | 07-07-2004 04:37 PM |
|
|
LinkBack | Thread Tools | Search this Thread |
Rating:
|
Display Modes |
|
||||
|
Array Declaration and For Loop
I am just stucked in syntax.This is more like a array and for loop problem.
I want to use ls -l command and get filezise and filename of all filenames in the directory in an array (say array#1). After 2 minutes of sleep, i want to get the same information in another array (say array#2). The command ls -l | awk '{print $9 " " $5}' prints all the filenames and then space and then the filezise of that file. I want to compare each array value and then get those filenames which have same size in both arrays. For example: Declare Array1...... >ls -l | awk '{print $9 " " $5}' File1 Size1 (copy this value in array1[0]) File2 Size2 (copy this value in array1[1]) File3 Size3 (copy this value in array1[2]) FileN SizeN (copy this value in array1[N]) After sleep 120, make another array called array2 and then Declare array2....... >ls -l | awk '{print $9 " " $5}' File1 Size1 (copy this value in array2[0]) File2 Size2 (copy this value in array2[1]) File3 Size3 (copy this value in array2[2]) FileN SizeN (copy this value in array2[N]) May be we can get new files after 2 minutes but we have to get all the rows in it. Then using a for loop, compare each value of array1 with array2 and where array1 value=array2 value, I have to get the value of array1 first argument (i.e. File name itself not the whole string which will include the filesize which is seperated by space). Please convert this to correct synatx in shell.Thanks. |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|