General :: Join 2 Variables In A Bash Script?
Aug 12, 2011
I have $db and $DATE set in my bash script, then I need to join them like this: mysqldump --user=usr --password=pss --databases $db | gzip > /backups/sqlNew/$db_$DATE.sql.gz;
Unfortunately, that doesn't work. How do I properly join those 2 variables into a filename?
View 1 Replies
ADVERTISEMENT
Mar 2, 2011
I am trying to understand the join command. I wish to join two files:
Code:
$ cat test1
a 0
b 2.51
c 19.85
$ cat test2
a 0
b 2.51
[Code]...
this is great but I do not understand why join ignores the -e flag and fails to insert FOO in the empty field.
View 1 Replies
View Related
Apr 6, 2011
mkvmerge -o <filename without extension>_TV.mkv -S <filename> && mkvextract tracks <filename> 3:<filename without extension>.*** && perl /home/brian/Desktop/ass2srt.pl <filename without extension>.*** && rm <filename without extension>.***
Doing these commands for multiple command line file inputs is the goal. So I can just type ./script.sh *.mkv in my terminal.This is what I have so far, but it doesn't work whatsoever.
View 2 Replies
View Related
Sep 13, 2010
Is there a difference when variables are referred to as $variableName and ${variableName} in bash?
View 1 Replies
View Related
Jan 23, 2010
I have a problem with a very big script I wrote in bash, and now I need to modulirize it in at least four smaller scripts. The problem is, that most of the variables I have will need to be shared by all scripts.
My question is: is there a way to declare global variables in bash? So that I can use and change them in any of the scripts and every change in the variable can be "seen" by the other scripts later.
View 4 Replies
View Related
Apr 4, 2011
I've created a script that put in dynamic variables the value HELLO 1, HELLO 2 HELLO 5. And I put the values of this variables in the file text.txt. Here's the script:
Code:
for i in $(seq 1 5); do eval ${i}=$(cat << EOF "HELLO" $i EOF); done
cat > text.txt << EOF
$1
$2
[Code]...
View 1 Replies
View Related
Apr 18, 2011
Can I pass javascript variables to bash script? If possible in bash script what code should I insert to receive javascript variables.
View 14 Replies
View Related
Aug 2, 2010
I would like to run a bunch of SQL commands from mysql client in bash. However, I would like to store the output in different variables. E.g.
Code:
var1=`mysql -u[user] -p[pass] -D[dbname] -e "Query1"`
var2=`mysql -u[user] -p[pass] -D[dbname] -e "Query2"`
[code]...
View 5 Replies
View Related
Nov 9, 2010
How do I concatenate two environment variables in bash?
View 3 Replies
View Related
Sep 7, 2011
I've been writing a bunch of bash scripts to make possible non-interactive, secure, cron-based SVN checkouts with CollabNet's SVN client and GNOME Keyring Daemon (aka GKD) and one of the scripts was designed to start GKD, harvest its output, essentially a couple of environment variables, and export those variables in shell of a user the script is run as. All upon user login by sourcing a bash script in ~/.bashrc.The problem is that those environment variables will not be exported, because the script is being run in a sub-shell that exits upon it completion and environment variables get unset for good.Well, the question is how can those variables be set permanently, meaning they're exported and kept untouched even across login-logout sessions?
View 1 Replies
View Related
Jan 2, 2011
I am using Linux some years, but since I built a LFS, I feel noobish again. Now with the help of BLFS I am setting up my environment and somewhere I incidentally read, that not every variable is inherited by a child Bash shell. As for the $PS1 and $PS2 variables I know, that they are not inherited by non-interactive Bash shells (and there is no reason why they should in my opinion). Well, as for my first thread I hope the title gives enough information on what I want to know. But anyways: Which environment variables are not inherited by Bash shells?
View 1 Replies
View Related
Jul 23, 2010
For example, if I'm in csh, I can use `setenv VARNAME varVALUE` while I can use export in Bash. Given that the environmental variables are created, can BASH read env vars from csh and vice versa?
View 2 Replies
View Related
Jun 21, 2010
I have a user that has been used for long time now that runs o C Shell... now there is a need to change it to Bash Shell? Can I cause a problem changing his shell from C to bash? I mean apps or variables?
View 2 Replies
View Related
Mar 6, 2010
I have made a simple bash script through which i can add, del, edit user from certain file using different CASE variables. like
case
1. adduser
2. del user
3. edit user
Now i want to add a exit CASE like
1. adduser
2. del user
3. edit user
4. exit
Now i want to make a script such a way that, if user input is 4 then only script quit. I used with exit function also but it didn't work. if user press ENTER or other keys then also it quit the program.
View 6 Replies
View Related
Feb 7, 2011
I was trying to redirect command output to a variable and realized that all the lines were joined. I tested this additionally with an example:
Code:
echo "The contents of this directory are " `ls -l` > dir.txt
and all the lines were joined in the resulting file. What can I do to preserve separate lines?
View 2 Replies
View Related
Jul 25, 2011
I'm trying to write a bash script, and for some reason Bash doesn't seem to like any of my variables _except_ the one used in a loop.What's going on? The same problem with MYS occurs regardless of its name, whether it is declared or referenced before, after, or inside the loop, and whether it is a string, integer, or floating-point number. Also, as far as I can tell, everything related to Bash is up to date.
View 7 Replies
View Related
Jul 26, 2011
I am trying to use the following bash alias:
I've been able to get this working under mac and solaris.
I've also tried not escaping the vars.
Anyone know if this is doable with ubuntu's bash shell? (or any meaningful workaround other than writing a script for this?)
View 2 Replies
View Related
May 10, 2010
I'm trying to write a bash script and I'm having trouble with it.I have a list of DNS entires from a file called zoneExport.txt.Than I want to parse a log file to see if that DNS entry has been queried for. So I'm running a grep command and trying to save it into a variable. What I'm looking for is a variable ($varGrepQ) that has the number of matches for the grep query. I will then run this through an if statement and do some things from there..
But my problem right now is with this grep query. It keeps outputting '0' even when I know there are records in that file and when I run the same query on the command line I get the actual count. My thought is that the $record variable is not passing right.
View 4 Replies
View Related
Nov 13, 2010
If I read in variables entered by the user, how can I check to make sure the correct number of variables were entered? For example, after reading in a data file and making it into an array, I have:echo "To check the data, enter the first element number, last element number and step size as x y z:"read x y z.It then goes on to start a loop, but what I would like now (before the loop) is a check to see if three variables have been entered, before the rest of the script continues.
I've tried specifying the variables as $1, $2 and $3, but if I echo $#, the value comes out as zero, so it's obviously not working.
View 9 Replies
View Related
Jun 6, 2010
Are there numerical variables (like type int in C) in the shell script language of bash? Say I want a counter to increment each time a loop is traversed.
View 1 Replies
View Related
Mar 18, 2010
I need to find the value of:
Code:
$Namenumber
My script asks for the name you want to look up and I want it to return the value of $Namenumber
I was thinking:
Code:
number=$"$name"number
but this returns
Code:
$Namenumber
but does not actually resolve what the variable $Namenumber is equal to.
View 4 Replies
View Related
Jun 25, 2015
I am trying to create scripts to move files over from one directory to an ftp server and there is this one file with spaces that bash is see each word as being a file, here is the variable i am trying to use:
Code: Select allLOCL = '/mnt/cifs/"File name with spaces"/'
cd $LOCL
ls -l
View 3 Replies
View Related
Feb 19, 2010
I created variables in python and would like to be able to incorporate those into bash commands that will be mixed into the script. Example:
Code:
name=raw_input("Type your name and press ENTER: ")
import os
os.system( echo "name")
Of course this doesn't actually work, but i think you get an indication of what I am trying to do.
View 1 Replies
View Related
Jun 9, 2010
Is there an easy way to get a line from a text file into a variable in a bash script?
I have a file called outside_temp that has a single number, say, 63.2
I would like to make a variable in a BASH script have that value.
I know how to use the input redirection and reassignment of stdin using code...
View 1 Replies
View Related
Mar 10, 2011
I have something like...
Code:
var=beer
# echo ${var/%e/E} doesn't do anything because i can only replace "r" or "er" this way
[code]....
View 1 Replies
View Related
May 4, 2011
I have a personal server and a dynamic IP address, so I wrote a script to check the currently assigned IP address and compare it to the one stored in a file from the last check, and visit the update URL if it's different.
View 4 Replies
View Related
Jul 7, 2011
I am trying to create a file, that has a variable assigned to it, in another directory. For some reason when I run the script it creates the file only in my pwd and I cannot for the life of me figure out why.My pwd at the moment is Desktop but it does not matter as I have tried from elsewhere. I have tried the touch command in the following ways (some will be obviously incorrect but I was desperate)and many more as well as the original format listed.
View 1 Replies
View Related
Mar 17, 2011
My question has to do with how environmental variables are passed from parent to child processes at the BASH SOURCE CODE level. I have a need to add an environmental variable that has the complete invocation line so that the child process can see it via ENVP.I have been studying the source for a quite a while and can't seem to find how to make the variable pass to the child. In EXECUTE_CMD.c I found a good place to set the variable: I made a routine similar to PUT_COMMAND_NAME_INTO_ENV called PUT_COMMAND_LINE_INTO_ENV which would add "?=THE FULL INVOCATION LINE" as an environmental variable but it doesn't make it to the child. (I've tried names other than '?' but they don't work either.
I'm thinking that there is either a LIST or a attribute associated with those environmental variables that should be passed to the child but I can't find it.
View 1 Replies
View Related
Jul 1, 2010
Is there a way to count the number of errors- an exit variable $? from one function?
The output from the exit variable (either erroneous or correct (1) or (0)) is it possible to add the erroneous one ups?
View 3 Replies
View Related
Dec 30, 2010
Trying to do a simple bash script, and having some issues. I am relatively new to bash, and did my best to search, but idk what exactly to search for.
Doesn't work code...
View 6 Replies
View Related