All Questions
113 questions
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 ...
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 ...
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[@]}"...
3
votes
1
answer
2k
views
What is the difference between ${array[*]} and ${array[@]}? When use each one over the other? [duplicate]
With the following code:
#! /bin/bash
declare -a arr=("element1"
"element2" "element3&...
1
vote
1
answer
5k
views
Putting string with newline separated words into array
I currently have a a bash variable that holds a string similar to this one,
where each different phrase is separated by a newline:
var="1st word
2nd word
4th word"
Note there is an empty ...
1
vote
2
answers
2k
views
Finding duplicates and their indices in an array in Bash
I want to find the duplicates in an array and their indices using bash.
For example, I have this array:
arr=("a" "b" "c" "a" "c")
In this case, "...
1
vote
2
answers
3k
views
Write values with embedded commas from arrays into CSV file using BASH
I am trying to write different arrays into a csv file ($file) columns.
Each array has the same number of values.
For example, arr1 and arr2 have 3 values each
arr1=( 23 45 34 )
arr2=( "abc,d"...
0
votes
1
answer
173
views
Write a bash script that displays, for each file given as an argument, the line that appears the most
Write a bash script that displays, for each file given as an argument, the line that appears the most. The display will be made in descending order of the number of occurrences.
I'm not sure how to ...
7
votes
2
answers
2k
views
Bash variables do not expand inside array if declare is used
Recently I decided to read a bit more on the bash built-ins declare, local, and readonly, which led me to switch from:
local variable_name
variable_name='value'
readonly variable_name
To:
...