General :: Bash Script: Use The Directory Of The Script File As Variable?

Jan 16, 2010

i'm not actually using Linux but i figured this might be the right place nonetheless..o i've got this little script file to compile and run some Java code:

Code:
#!/bin/bash
cd /Users/acid/Desktop/javaTest

[code]...

View 12 Replies


ADVERTISEMENT

Programming :: Bash - Read Content Of File To Variable And Use This Variable In For Loop ?

Aug 21, 2009

I'm trying to read content of file to variable and use this variable in for loop. The problem is, when I have c++ comment style in file - /*. Spaces in line are also interpreted as separated lines.

For example:

Code:

Changing $files to "$files" eliminate these problems but causes that whole content of variable is treated as one string (one execution of loop).

View 6 Replies View Related

Software :: Get Variable From Text File Into Bash Variable?

Jun 10, 2009

I have a text file i that has a mailTo: NAME in it. In a bash script i need to extract NAME and put it in a $variable to use. How do i do this?

View 2 Replies View Related

General :: Reading File Into Variable In Bash?

Mar 21, 2011

I know that cat can output the file, but how do you store that output in a variable to process:

Code:

CONTENT=cat file.txt

This doesn't seem to work?

View 3 Replies View Related

General :: Pull String From A File Into A Variable Using Bash

Aug 6, 2011

I have a file (.tmpfile) and inside it is a string which i only know part of, the rest being a random group of characters... I would like to know how to pull the whole string out of the file and into a variable.

View 13 Replies View Related

General :: Bash - HISTSIZE - Readonly Variable -bash - HISTFILESIZE - Readonly Variable

Dec 8, 2009

On one of my servers I see this when I log in. What does this mean and how can I get it to go away? Everything seems to work fine, but none of my other machines give this error.

View 5 Replies View Related

General :: Bash - Finding Newest File In A Directory?

Aug 24, 2010

Basically, I am trying to locate and copy the newest .json bookmark backup in my .mozilla/firefox/w987sdg9.default/bookmarkbackups directory.

I tried this

Code:

ls -t ~/.mozilla/firefox/b1ahb1ah.default/bookmarkbackups/ | head -1

which does return the newest file, but only the filename itself. I found readlink, but I haven't gotten that to output a full path which I can then feed to copy. So, it seems to me that find might work well here, and I know how to find based on absolute dates, but not relative.

View 2 Replies View Related

Debian :: Sed With Bash Variable In Rules File

Jun 6, 2015

How can we do a file replacing string on debian/rules file using sed and bash variable ? I don't seem to be able to do so. I have tried below under the install section with arch dependent amd64, as far as I know all the bash commands are allowed to be executed in debian/rules file.

I have tried this :

Code: Select all
debian/rules file
ipaddr=`<long command to find ipaddr>`
myVar=`hostname`
sed -i -e 's/somestring/'$myVar'/g' $(configs)*
sed -i -e "s/somestring/$myVar/g" $(configs)*

[Code]...

Nothing works. Sed works but the hostname replacement doesn't work.

View 13 Replies View Related

General :: File Names And Tilde--not For Home Directory--in Bash?

Jun 6, 2011

I understand the tilde (~) at the end of a file displayed in bash is a backup file in the Linux file system. Is there a way to keep these hidden when listing the contents of a directory?

View 2 Replies View Related

General :: Cannot Move A File Into My Archives Directory In Bash Scrip

Apr 12, 2010

I cannot move a my file into my archives directory in my bash scrip.

View 7 Replies View Related

Ubuntu :: Read A Variable From File (bash Script)?

Nov 8, 2010

I googled and tried to find an easy step by step-by-step guide on how to use a bash script read a variable from a file. This is the way I did it (but it does not really work so something is wrong, but what?) (testfil2 contains one line that readsidnumber=1578

#!/bin/bash
value="/home/user1/Desktop/testfil2"
echo $value
kill $pidnumber

View 4 Replies View Related

General :: Remove Index.html File Alone In Every Directory Via Bash Script

Jul 7, 2011

I want to remove the index.html file alone in the every directory via bash script, for example i have 5 directories in the path /var/www/vhost

anish
kumar
linux
question
friend

each directories have index.html file now i want to replace the index.html file alone from the other directory /var/tmp/vhosbak

anish
kumar
linux
question
friend

How we can do this using script?

View 5 Replies View Related

General :: Using For The Server - Bash: /etc/init.d/dhcpd.conf: No Such File Or Directory

Aug 24, 2010

# /etc/init.d/dhcpd.conf -bash: /etc/init.d/dhcpd.conf: No such file or directory what is the problem? and how to configure out "joe"

View 5 Replies View Related

Ubuntu :: Directory Exists But Bash Says It Doesn't - No Such File Or Directory

Aug 19, 2011

I've run into a problem with my bash program.

Code:a mkdir -p /home/chris/Downloads/ARCHIVE/`date -I` find /home/chris/Downloads* -mtime +14 -exec "cp {} /home/chris/Downloads/ARCHIVE/`date -I` ;

It's meant to move old files from my Downloads folder into an archive file (later tar them). The directory exists, I've used $PWD and nautilus and ls to make sure it's there, yet for every file it gives

Code: find: `cp /home/chris/Download/foo.bar /home/chris/Downloads/ARCHIVE/2011-08-19': No such file or directory I tried to test it on a different destination, specifically my home folder. IT still gave me the error.IS it a bad syntax within find or something else? I'm running a 32-bit system with 11.04

View 4 Replies View Related

Programming :: Bash Scripting...read A Value From A File Then Assign To Variable?

Feb 27, 2011

At my wit's end I can't find anything that I understand well enough to use. This is for a Unix class, we are working with shell scripting. File1 has 5 in it and File2 has 100 in it.The teacher wants us to read the values then do the math. This is what I have so far:#!/bin/bashvar1='cat File1'var2='cat File2'var3=`echo "scale=4; $var1 / $var2" | bc`echo The final result is: $var3

View 9 Replies View Related

Programming :: Parse Multiple Variable From Text File With Bash?

Jul 13, 2010

I am trying to think of a logic where my file contains some data I had to read and do some processing. Issue is that file contains data multiple times. For example:

:::::::::::
var1=value1
var2=value2

[code].....

I have to read first paragraph of variables and do some processing and then move on until the end of file. Variable names are same in whole file but for each paragraph the value is different. I can't think of a logic to attain this task. How can I do it? It should be a simple bash script, but I am not able to work out.

View 2 Replies View Related

Ubuntu :: Help With Bin File - Error Message - Bash - /hldsupdatetool.bin - No Such File Or Directory

Jun 9, 2009

I am new to Linux and I wanted to setup a dedicated game server on my notebook.

I've installed Ubuntu 9.04. I than created a directory named /home/phlex/kfserver. I downloaded the application binary from Steam. I changed the file permission with chmod +x hldsupdatetool.bin and now the file attributes are -rwxr-xr-x.

The problem is when I try to run the binary file. If I type ./hldsupdatetool.bin I get an error message "-bash: ./hldsupdatetool.bin: No such file or directory. It seems the OS can't find the file. I've downloaded the file several times thinking it may have been corrupt but it's not. I can delete the file, I can rename it and so the file is there. Sometimes Linux can be aggravating to use.

View 7 Replies View Related

General :: Get N-variable Parameters In Bash

Mar 21, 2011

I've a script that it's invoked with n-variable parameters. Here's an examples:

Code:
./myprogram.sh inputdir FIELD1 FIELD2 ... FIELDN outputfile In the script I would like to get the FIELD names that were passed.

View 4 Replies View Related

General :: Substitute Variable In Bash

Mar 21, 2011

Assume that i a having the following three lines in an executable file

#/bin/bash
a=Tue
Tue=1

When i give echo $a the value should be 1, how to do this.

View 8 Replies View Related

General :: Bash: Input Password Into A Variable?

Aug 22, 2010

I'm basically setting up two sshfs mounts and I have it set up so I run one command but type my password twice.Is there an easy to way to input a password using bash and pass that variable to another process asking for a password?

View 5 Replies View Related

General :: Bash Variable As Parameter To Script?

May 10, 2011

I want to create a variable that when passed as a parameter to another bash script will keep its string quotes (so it stays as one parameter). What ways can I achieve this cleanly?

Code:

john@ubuntu:/usr/local/src$ cat foo.sh
#!/bin/bash
echo $0

[code]....

View 8 Replies View Related

General :: Concatenate Variable Names In Bash?

Apr 7, 2011

In my script, and I would like to concatenate 2 variables names, to give me the true variable.I've 3 variables X1, X2 and X3, and I invoked them inside a for loop.

Code:
#!/bin/bash
X1=HELLO

[code]....

View 4 Replies View Related

General :: Bash Catching The Function Returning Value Into A Variable?

Mar 17, 2010

i am dealing with this problemI have a function

function Une {
...
return $some_variable

[code]...

View 6 Replies View Related

General :: Bash Script - Forget Global Variable's Value?

Apr 9, 2011

I have a hard time with my bash script.

It forget global variable's value.

First look at my script.

Code:

Echo "PKGS is [$PKGS] in after loop"

And data file for it is below. Let's name as list.txt

Code:

As you see, PKGS variable in loop has correct value.

However, after loop I can not get proper value for it.

View 5 Replies View Related

General :: Simple Bash Command Causing Bad Variable Name

Feb 18, 2010

When I run this command from shell, it runs ok
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
However when I save it into a file called test.sh (of course, I chmod it with +x), I got error "export: 2: bad variable name"

Here is the file:
#!/bin/bash
export REVS=`svn info svn+ssh://svn.myone.ca/var/svn/story/trunk/lib |grep 'Last Changed Rev:'| awk -F: '{print $2}'`
I am using ubuntu.

View 7 Replies View Related

General :: Bash Script Variable NULL Instead Of Value Of Expression?

Nov 17, 2010

Quote:

#!/bin/sh
for i in {1..10}
do
for j in {1..50}

[code]....

The first echo generates something like: abc.de.fgh The second echo generates:

View 3 Replies View Related

General :: Environmental Variable In Bash Command String?

Feb 9, 2011

I do this:

Code:

a@b:~$ export A=hi
a@b:~$ echo $A
hi
a@b:~$ bash -c "export A=blah; echo $A"
hi
a@b:~$

Why doesn't the bash command print the new value of $A? Is there a way to make it do so?

View 6 Replies View Related

Ubuntu :: /bin/bash: : No Such File Or Directory

Jan 20, 2011

I had netbeans installed and I removed it using wheris netbeans and then sudo rm whatever files it gave.I also remember doing sudo rm -r /usr/lib/netbeans6.9 I did this because i wanted to install netbeans via the repo. Now I installed netbeans suing

Code:

varun@varun:~$ sudo apt-get install netbeans

and when I try running netbeans i get...

Code:

varun@varun:~$ netbeans
/bin/bash: : No such file or directory

Have i changed permissions or something?

View 1 Replies View Related

CentOS 5 :: -bash: /usr/bin/yum: No Such File Or Directory

Feb 8, 2011

I upgraded my php from 5.1.6 to 5.2.10 but at php -v I got a weird error, so I figured let's reinstall some things. This was the probably very dumb commando I used:

yum remove gcc-c++l zlib zlib-devel php*

Now I think my whole server is fxxxed because I get the following messages:

-bash: /usr/bin/yum: No such file or directory
-bash: rpm: command not found
-bash: ls: command not found

And the only thing I'm glad about is I still have an SSH connection open because creating a new connection isn't possible either. what should I do to repair this all.

View 3 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved