Questions tagged [array]

A array is the simplest data-structure for storing items in continuously memory

25 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
2
votes
4answers
123 views

summing two matrixes each one in a different file

i have 2 files each contains like the following: file 1: data : [ 56, 34, 23, 54, 90, 234, 53, 12 ] file 2: data : [ 42, 56, 23, 98, 90, 23, 53, 32 ] i want to sum 1st value from ...
1
vote
0answers
34 views

Performing job array by reading in file paths from a text file

I am trying to perform a job array using script below. #!/bin/bash --login #$ -cwd #$ -t 1-4 module load apps/bioinf module load apps/trimmomatic/0.36/noarch file=`awk "NR==$SGE_TASK_ID" ~/scratch/...
1
vote
0answers
25 views

Set i'th value of kernel module array with command line arguments

Given a kernel module arraymod.c with the following array declaration: static int myintArray[2] = { -1, -1 }; static int arr_argc = 0; module_param_array(myintArray, int, &arr_argc, 0000); ...
1
vote
1answer
140 views

Better way to retrieve n-th (index) positional parameter value in `ash` then `eval echo \$$n`?

I'd wish the user to select a file from a numbered list on screen in a mkinitcpio busybox ash environment. The list needs to be filled/sorted from top to bottom and printed in columns, like: 1) 2017-...
1
vote
1answer
272 views

How many elements can an array store in unix script?

I need to check the file permissions of directories /usr, /tmp, /var and their contents of sub directories. I have taken the file permissions of the directory and its sub directory files in an array ...
1
vote
1answer
705 views

How to give multidimensional array a value for each 'cells'

I'm not a programmer at all, but I need to write a script to cut a file and produce a multidimensional array from this file. I'm a chemist, so my array should be something like: [pe][pH][element][...
1
vote
1answer
551 views

Populate array with a sed/echo combination

I'm trying to rename multiple files containing dates. I want to split the date into year, month and day and then create a new filename in a directory tree like year/month-year/filename_yearmonthday....
1
vote
0answers
179 views

Returning an array from a ksh93 function

I would like to return an array from a function in ksh93. At this point, using the following method, the contents of the array are passed as a single element even though, in the fonction, the array ...
1
vote
1answer
102 views

Shell script: Text files to array

I must use C-shell. I have a 40+ list of ip and hostname in text file. sat1 100.34.54.65 sat2 100.34.54.55 sat3 100.34.54.45 and so on.. i want to set the ip and hostname as list of array. The first ...
1
vote
2answers
408 views

Efficient way to search array in text file by AWK

I have one array SPLNO with approx 10k numbers.Now i want to search the subscriber number from MDN.TXT file (containing approx 1.5 lac record)from the array.if subscriber number found in array it will ...
1
vote
1answer
198 views

awk array using number as value did not work

I have a reference file: Refrence File Dpse\GA30012 FBgn0000447 chr2 26607738 26607962 -1 Dpse\GA19764 FBgn0085819 chrX 28571020 28571736 -1 Dpse\ttk FBgn0000100 chr2 ...
0
votes
0answers
54 views

How can I get a continent array from a country list in python?

I have a list of countries and I need to create an array of continents in which each country is. I already tried with geopy module but my console do not allow me to use it. Also, I can't use ...
0
votes
0answers
15 views

Attempting to write PHP array to file in Linux PHP interactive shell produces Uncaught Error and empty file

After executing the following commands: [root@server test]# php -v PHP 7.2.25 (cli) (built: Dec 17 2019 22:57:09) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-...
0
votes
0answers
54 views

Bash array length - my code always gives 1 or 0 but should have infinite varaibility

Yes similar questions have been asked, but none of those answers have shown me what I am missing here. I think my problem is in not fully understanding what I am generating with my code... ...
0
votes
0answers
45 views

Comparing Timestamps

My users sometimes get alerts with a timestamp, (from another system, via email) but no hostname. I want to give them a function that can compare timestamps in my system that's designed like this: /...
0
votes
0answers
43 views

Delete a character from the last line of a bash array

I would like to do the same thing as this topic but with bash in version 4.1.2. I can get the chain I want with the following command: echo ${arr[@]:(-1)} | sed "s/,$///" However, I would like to ...
0
votes
1answer
75 views

Check that 2 arrays of file names are the same

So I have the following: cat file | grep -E regex which gives a list of lines Now I also have a for loop the produces a list of files So it is like I have 2 arrays. But how do I check in bash if ...
0
votes
1answer
280 views

Sed search and delete matching two patterns one of which is a variable

I have a file that contains multiple instances of code that I need to delete. Here is an example: !/bin/bash mkdir /rootdir/pipeline_runs/oncology/analysis/sample_1_NA172_1 cd /rootdir/pipeline_runs/...
0
votes
1answer
14 views

RHSA installation in RH7

this is a question similar to the mine I asked you yesterday (how to iterate installation in a row). I need a script that starting from an RHSA list as argument, separated by " " spaces, it performs ...
0
votes
1answer
230 views

Using variable to retrieve array element inside awk statement

Below is the part of the code that is throwing error. for (( p=0; p<${var2}; p++ )) do if [[ ${array2[$p]} == *"xyz"* ]] then awk -F" " '{ array3[p]="123" };1' ${array1[$i]} else awk -F" "...
0
votes
1answer
1k views

parse snmpwalk output to array

Im trying to get network interfaces by doing a snmpwalk, but cannot separate in array, the variable stores all in element 0 ifname=(\$(snmpwalk -Oqv -v2c -c comm xxx.xxx.xxx.xxx 1.3.6.1.2.1.2.2.1.2))...
0
votes
0answers
114 views

How to resolve a variable's value inside an array in bash

I have a few files whose names I have assigned into variables. (There may be n number of files). Those variables are passed into an array. Now I want to print the names of the original files using ...
0
votes
2answers
541 views

How can I assign the last element of an array to a another array?

Let say I have an array $Info whose elements are ; ! total energy = -1090.13343774 Ry ! total energy = -1090.20757070 Ry ! total energy = -1090....
0
votes
0answers
52 views

Array value won't get printed out

I have the below bash script, but rather that I get the command executed stored in cmd[1] it prints [1]: command not found. I executed the command with the following way: $ qsub -J 1-33 sicer-pbs.sh ...
-1
votes
1answer
43 views

UNIX AIX using Array to store name and path then get them using for loop separately

I have a script in which i need to create an array with the Path and Name of some files, then i need to pass the Path and Name separately to another script after checking the user's arg matching one ...