All Questions
7 questions
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
402
views
Mathematical operations - Bash script
I am trying to write a script(script1.sh) that gives the sum of each digits in the first number, raised to the power of second number. So
./script1.sh 12345 2
should output 55
(because 1+4+9+16+...
0
votes
1
answer
105
views
Start range from 1 onward
I am counting multiple log files with the range starting from 1 onward however it's starting from 0.
path=(/home/folder/text/*)
for 1 int ${!path}; do
printf "$s: $s\n" $i "${list[i]##*/}"...
0
votes
2
answers
222
views
Unix Script, problem with a 2d array
I have 2 arrays that refer to files for example
alpha=file 1
beta=file2
Charlie=file3
delta=file4
beta2=file5
beta3=file6
Charlie2=file7
charlie3=file8
delta2=file9
delta3=file10
array1=("$alpha" "$...
1
vote
2
answers
1k
views
Using awk to process multiple files need to count occurance of variable after pattern. How can I stop array resetting after each file?
I want to count all occurances of any variable in parenthesis after patterns, for files in a directory that have a specific extension. Each file may contain the pattern on multiple records/line.
So ...
2
votes
2
answers
6k
views
for loop not working for multiple lines
I have a array like this "Apple Banana Clementine Date"
I have to print like this:
1. Apple
2. Banana
3. Clementine
4. Date
Script file:
for i in "${fruits[@]}"; do
echo "$lineno. $i "
...
0
votes
1
answer
299
views
How to do a control loop
this is what I figured out in sorting an Array that has already had it's elements declared type int
#!/bin/bash
#sorting an "predeclared" array
typeset -i store BigNum
let store=0 BigNum=0
...