UNIX Why are my array values not returning correctly? UNIX

2017-04-18T04:47:13

I want to write a script such that when I call
ls -lp | insertScriptNameHere

it stores the text sent to it int an array,

this is what I have in VI so far

#!/bin/bash

declare -i int =0

while read line; do    

array1[$int]="$line"

done

for ((int=0; int<=${#array1[x]}; int++));

do

echo $array1[$int]
done

this is producing a very strange output, it is copying the final line sent to it 61 times, I am new to unix and unix syntax, so please do not get mad if I am missing something very basic, I feel as though my logic is correct, i feel im messing up my syntax

Copyright License:
Author:「Anyon」,Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.
Link to:https://stackoverflow.com/questions/43459324/unix-why-are-my-array-values-not-returning-correctly-unix

About “UNIX Why are my array values not returning correctly? UNIX” questions

I want to write a script such that when I call ls -lp | insertScriptNameHere it stores the text sent to it int an array, this is what I have in VI so far #!/bin/bash declare -i int =0 whil...
I need an array sorted by Unix timestamp values. I attempted to use both ksort and krsort before realising that occasionally the timestamp values might be the same (and you cannot have duplicate ke...
Not sure what the problem is here. I use time.time() and I get 1492374538, which translated is Sunday 16th April 2017 01:28:58 PM; this is via the Pycharm python console. Although the local time is
I have a unix script like this: value1=`sqlplus -s ivr/ivr &lt;&lt;EOF set heading off; set feedback off; set linesize 500; set serveroutput on; set wrap off; SELECT FM.getSequen...
Looking for help with this conversion. month day year hours minutes seconds to UNIX Code is running, but we are getting incorrect conversions. Main Column is our DateTime column. Imports import os ...
I have a wired situation here with returning the time in unix format. I have this function: def get_today_date(): nowDate = str(datetime.datetime.utcnow().date()) unix_date = time.mktime(da...
I try to declare an array and access its contents like this declare -a VAR VAR[0]=text1 VAR[1]=text2 VAR[2]=text3 echo $VAR[1] But it doesn't work. Can you fix my code and also tell me why we don't
I'm trying to return the list of Unix users on this perl script. I'm using the Mojolicious framework with Passwd::Unix. References: Mojolicious (http://metacpan.org/pod/Mojolicious) Passwd::Unix ...
I am given a 2D numpy array and a huge pandas DataFrame. A dummy example of them would look somewhat like this: arr = np.array([[1648137283, 0], [1648137284, 1], [
I have an MSDOS 6.22 application which uses NFS to access files on a Unix server. It shows file dates 20 days older than the actual file date on the server. A DIR command shows the same incorrec...

Copyright License:Reproduced under the CC 4.0 BY-SA copyright license with link to original source & disclaimer.