All Questions
11
questions
0
votes
1
answer
542
views
Why do these rsync filter args fail in bash when passed in array?
Why does this rsync command work when I give it literally but not when I create it from variables?
Here are the variables - first the options I'm passing to rysnc, as an array:
$ echo "${options[@]}"...
4
votes
4
answers
3k
views
Correctly quote array that is being passed indirectly via another command
I need to pass an array of filenames to a command, preserving proper quoting. So far, so good. Unfortunately the command is actually a sub-command that is, in turn, invoked by another command. ...
1
vote
3
answers
2k
views
Why does double quoting an array expansion in here document not seem to work here?
I have two arrays
$ arr1=( 1 2 2 3)
$ arr2=( 2 3 3 4)
Why does this generate strange output when I follow the good practice of double quoting an array expansion
$ tsort << EOF
> "${arr1[@]}...
0
votes
2
answers
126
views
Bash : Give builded array to function as a list of argument?
I have this issue with borgbackup, but because the reaction is the same, I will use rsync in my example.
I want to build an array of arguments by adding a prefix to each, and then give that array to ...
2
votes
2
answers
931
views
Index range of array doesn't allow you to iterate over a new line in bash
I'm working on a simple bash script that fixes a duplicate naming issue on a retropie.
The script itself grabs any name that is mentioned more than once in a gameslist.xml file, then stores those in ...
4
votes
1
answer
4k
views
How do I join an array of strings where each string has spaces?
My bash script:
#!bin/bash
MY_ARRAY=("Some string" "Another string")
function join { local IFS="$1"; shift; echo -e "$*"; }
join "," ${MY_ARRAY[@]}
I want the output to be:
Some string,Another ...
4
votes
1
answer
12k
views
Problems creating array with newline separator
I'm building a function to find large directories on the filesystem and the /n is being cut off of /native/proc... in each of my array elements containing that path. I believe this has something to ...
3
votes
1
answer
1k
views
bash add value to array with embedded variable and single quotes
I'm sure it's completely clear from the subject :) Joking aside, I think part of the problem I'm having finding an answer is writing the search terms.
I have had good luck when issuing commands in a ...
6
votes
3
answers
4k
views
Passing multiple of arguments with whitespaces through a script to ssh
I want to remove multiple files from remote server. I have all files under one array in a script and I call other script which will remove files.
Let output of "${b[@]}" is:
/mnt/DataBK/...
5
votes
2
answers
7k
views
Splitting the working directory in a bash script
If I do:
IFS="/" read -ra PARTS
And type in a path manually, it creates the array "PARTS" as hoped, however:
IFS="/" read -ra PARTS <<< $(pwd)
creates an array with a single element, with ...
4
votes
2
answers
2k
views
How do you preserve a space in a literal expression in an array value in bash and how to trim down results from a sort command?
In the context of searching for expressions in log files, I was wondering generally if there was a way to quantify and qualify the contents of the logs in /var/log in some way. In particular, does the ...