Linked Questions
13 questions linked to/from How to read a space-delimited string into an array in Bash?
0
votes
1
answer
98
views
How to loop commands continuously from prompt [duplicate]
Is there a way to loop the commands until the number of names from the prompt, i dont want it to just limit the number of users but to continuisly add names to the prompt while repeating the line of ...
63
votes
6
answers
90k
views
Convert multiline string to array [duplicate]
I have this script:
nmapout=`sudo nmap -sP 10.0.0.0/24`
names=`echo "$nmapout" | grep "MAC" | grep -o '(.\+)'`
echo "$names"
now the $names variable contains strings ...
86
votes
4
answers
40k
views
What does the Bash operator <<< (i.e. triple less than sign) mean?
What does the triple-less-than-sign bash operator, <<<, mean, as inside the following code block?
LINE="7.6.5.4"
IFS=. read -a ARRAY <<< "$LINE"
echo "$IFS&...
5
votes
2
answers
5k
views
How do I iterate through each line of a command's output in bash?
I have a script that reads from /proc/stat and calculates CPU usage. There are three relevant lines in /proc/stat:
cpu 1312092 24 395204 12582958 77712 456 3890 0 0 0
cpu0 617029 12 204802 8341965 ...
2
votes
3
answers
4k
views
In bash, how to generate all possible word combination, but in original order?
From the line:
word1 word2 word3 word4 word5 word6
How to return the following:
word1
word2
word3
word4
word5
word6
word1 word2
word2 word3
word3 word4
word4 word5
word5 word6
word1 word2 word3
...
-1
votes
1
answer
2k
views
Shell script to separate values in each line and put it in two variables [duplicate]
I have a text file with 2 values in each line. I need to put these two values in two different variables i.e var and var2 and do further processing for each line. The delimiter is space between the ...
0
votes
1
answer
1k
views
GNU Make: How to set an array from a space-separated string?
I'm writing a Terminal Match-Anything Pattern Rule, i.e. %::, that, as expected, will run only if no other target is matched. In its recipe I want to iterate over makefile's explicit targets and check ...
0
votes
2
answers
683
views
Bash and IFS: string split to an array with specific separator add an extra empty element
About split a string into an array we have two scenarios:
if the string has empty spaces how a separator, according with the following post:
Reading a space-delimited string into an array in Bash
So ...
0
votes
4
answers
144
views
Assigning variables in a for loop
Ive got a file called school.test and it looks like this:
David maths
Sam maths
Sam english
Simon french
Simon english
I want to write a for loop which reads this ...
2
votes
1
answer
119
views
What does oarr=($output) do in shell?
On https://www.virtuability.com/public/wp/?p=12 I saw this notation:
oarr=($output)
export AWS_ACCESS_KEY_ID="${oarr[1]}"
export AWS_SECRET_ACCESS_KEY="${oarr[3]}"
export AWS_SESSION_TOKEN="${oarr[4]...
0
votes
1
answer
305
views
Different behavior of loop in github action and unix
My requirement is to iterate through checked in files in a loop and perform the action:
My GitHub Actions workflow is:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout repo ...
0
votes
1
answer
145
views
Separate string read from CSV into array is not working
So I have my CSV file which looks like that:
repo_name1,path1,branch1 branch2
I read it with following code:
INPUT=repos.csv
OLDIFS=$IFS
IFS=','
[ ! -f $INPUT ] && { echo "$INPUT file ...
-2
votes
4
answers
66
views
Modify BED with poliregions [closed]
I have a somewhat tricky BED file format, which I should convert to a classic BED format so as I can properly use it for further steps:
I have this unconventional BED format:
1 12349 12398 +
1 ...