All Questions
Tagged with shell-script array
178 questions
1
vote
4
answers
114
views
Need shell script help - processing the same option multiple times
So I've ran into a bit of a wall, I have an option in my script that calls a function which allows me to specify a file/directory and then I want to parse that output into a menu tool (using dmenu in ...
5
votes
4
answers
813
views
Pass multiple files as a single option
I'm trying to build a wrapper to execute a tool multiple times, then concatenate some of the results. I'd like to pass two sets of files to my wrapper script, then run the tool for each pair of files. ...
4
votes
4
answers
478
views
How to sort the list of positional parameters in POSIX sh
Is there a way to sort the list of positional parameters in POSIX sh? Each positional parameter could contain arbitrary characters (e.g. spaces, newlines, tabs, etc.). The sort algorithm should be ...
1
vote
2
answers
270
views
Getting an array of files built from include array and exclude array containing globs
I am wanting to do the following:
Define an array of globs that specify a base collection of files to include in a process.
Define an array of globs that specify files to exclude from that process. ...
2
votes
1
answer
564
views
What is difference between these two declarations of associative arrays in Bash?
I am playing a bit with associative arrays in Bash and I found the following difference when declaring the exact same associative array with and without declare. The code is as follows:
#!/usr/bin/env ...
2
votes
2
answers
603
views
For loop through a variable vector
I have a for loop and case statements. The for loop has quite a bit element list and the case statement will assign an 1D array or a vector. These values will be used in for loop after. I have the ...
0
votes
3
answers
274
views
In a bash script, loop through a bash array for input to a binary
I'm running bash.
Suppose I have a binary mybinary that takes interactive user input.
Suppose that mybinary takes attendee names as input until the user types q and presses Enter (q for "quit&...
0
votes
2
answers
421
views
Sort file array list in bash by date and bypass argument limit
So, I have a file array list in a bash shell, and I want to sort all the files in the array by the date modified, starting with the oldest being the first one in the array. However, I don't want to ...
0
votes
1
answer
58
views
linux bash shell script - pass through function array variable
So in order to be versatile, I make a lot of functions and i want to define my own variable name when i call on that function.
For basic text, numbers it works and this is how I do it
function ...
2
votes
1
answer
535
views
Capture output of a command that get stuck
I am trying to use regex for capturing some text pattern in an ouput of a command and create an array list_mqs. The problem is that this previous command get stuck and never terminates. So, when I use ...
1
vote
1
answer
1k
views
Create an array from the output of whiptail command
So, I am trying to use whiptail command to give users option to choose different things they want to install in their system.
I use the whiptail --checklist command as below:
name =$(whiptail --title &...
0
votes
1
answer
885
views
convert a uint8 array ( javascript new Uint8Array() ) to binary format (or binary mode ?) in shell / bash?
The question is about convert from new Uint8Array() generated from javascript into a normal file (file that can be used with other programs like ffmpeg)
** I don't know the right term to use if it's ...
2
votes
5
answers
617
views
match value2 in 2 files if value 1 is exact match
I have 2 files containing list. Column 1 is userIds & column 2 is associated values
# cat file1
e3001 75
n5244 30
w1453 500
#cat file2
d1128 30
w1453 515
n5244 30
e3001 55
Things to consider.
...
1
vote
0
answers
1k
views
Create a tsv file with data from several files
How can I create a tsv file from multiple files?
I want to be able to create a tsv file from several different files. One sample is associated with five 'region' files that have data in them. For ...
5
votes
2
answers
14k
views
How to pass an array as function argument but with other extra parameters?
The following post solution works as expected:
How to pass an array as function argument?
Therefore - from his answer:
function copyFiles() {
arr=("$@")
for i in "${arr[@]}"...