Skip to main content

All Questions

Tagged with
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[@]}"...
markling's user avatar
  • 213
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. ...
Konrad Rudolph's user avatar
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[@]}...
Tim's user avatar
  • 103k
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 ...
Vlycop Doo's user avatar
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 ...
RobotJohnny's user avatar
  • 1,047
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 ...
Username's user avatar
  • 859
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 ...
jesse_b's user avatar
  • 37.6k
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 ...
roger's user avatar
  • 243
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/...
AVJ's user avatar
  • 505
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 ...
Brent's user avatar
  • 214
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 ...
user avatar