2
votes
1answer
30 views

Passing two values from awk to bash

I have a list of value in which I am looking for the highest and the lowest value using awk inside of bash. I am able to find these, but I'm unable to assign the values to some variable so I can use ...
0
votes
2answers
14 views

conditional statement in bash with mysql query

im trying to write a bash script that will do a mysql query and if the number of results is 1, do something. i cant get it to work though. #!/bin/sh file=`mysql -uroot -proot -e "select count(*) from ...
1
vote
3answers
42 views

Save variable from txt using awk

I have a txt in my folder named parameters.txt which contains PP1 20 30 40 60 PP2 0 0 0 0 I'd like to use awk to read the different parameters depending on the value of the first text field in ...
0
votes
1answer
26 views

bash expand variable in a variable, with $ as prefix

I am working on a bash function, and I suspect that it currently has a syntax error, the code is this: for (( i=1; i<$#; i++)) do GET_BLOCK "/$${!i}/" ... done What I am trying to do is to run ...
2
votes
5answers
60 views

Remove substring matching pattern both in the beginning and the end of the variable

As the title says, I'm looking for a way to remove a defined pattern both at the beginning of a variable and at the end. I know I have to use # and % but I don't know the correct syntax. In this ...
1
vote
2answers
33 views

Bash variable space in directory path

How can I remove a white space when I use a variable in a directory path. For example, I'm trying to do alias test='echo /david/$1' and when I try test hhh this produces /david/ hhh with a ...
1
vote
2answers
26 views

Create timestamp variable in bash script

I am trying to create a timestamp variable in a shell script to make the logging a little easier. I want to create the variable at the beginning of the script and have it print out the current time ...
1
vote
1answer
68 views

What Unicode symbols are acceptable in BASH variable names? [duplicate]

What Unicode symbols are acceptable in BASH variable names? Does the same list of symbols apply to CSH and TCSH?
0
votes
2answers
29 views

How to use a variable name in a Perl Regex bash script

I am trying to write a bash shell script to rename a bunch of photos to my own numbering system. All images filenames are like "IMG_0000.JPG" and I can get the script to match and rename(overwrite) ...
4
votes
6answers
72 views

BASH - How to read file contents to insert results into mysql WHERE clause

I'm trying to make a file (call it accounts) and have a bash script (call it *name_checker*) loop through each line and make it into multiple strings to store in a variable called '$NAMES' for a mysql ...
2
votes
2answers
45 views

Bash shell scripting - Error setting variables

I'm new at bash scripting. I tried the following: filename01 = '' if [ $# -eq 0 ] then filename01 = 'newList01.txt' else filename01 = $1 fi I get ...
0
votes
1answer
26 views

String concatenation does not work in Bash cygwin

Tell me this, why this code does not work in Cygwin ? I've tried use \. and different symbol combinations between variable. Scopes tried too ( round, figure ). Dunno what up. My code is here and it ...
-1
votes
2answers
41 views

Bash: update variable that uses a updated variable

I am trying to get a little Backupscript running and I'm kinda stuck with something maybe so easy, but I cannot get it to work. I use echo "backup 1 started" / echo "backup 1 ended" after each part ...
2
votes
1answer
26 views

Global variable is reset if loop send output to pipe

According the bash(1) man pages, when I run the following: set -e x=2 echo Start $x while [ $((x--)) -gt 0 ]; do echo Loop $x; done | cat echo End $x The output will be: Start 2 Loop 1 Loop 0 End ...
1
vote
3answers
32 views

How to read input, save it to a dynamically-named variable and check if given input was empty

Consider a generic ask() function that asks the user a question, reads the input and saves it in a variable named according to one of the function's arguments. ask() { local question="$1" ...

1 2 3 4 5 26
15 30 50 per page