General :: Sed Substitution Of Variable With A Variable?

Dec 27, 2010

I am trying to alter the character position of residue numbers above 999 in a pdb file.The following script is an attempt to:1) Get all unique pdb residue numbers (in column 5) using awk and assign it to a variable i.2) Loop through all the values in $i and if it is greater than 999, shift that number one character to the right using sed.However, the script only manages to alter the final residue numberCould anyone please advise how I can loop through all values in $i and shift it one character to the right?

#!/bin/bash
# Script to alter position of residue number in pdb file for resid above 999
i=$(awk '{print $5}' wt-test.pdb | uniq)

[code]...

View 6 Replies


ADVERTISEMENT

General :: Shell Script -- Awk Variable Substitution?

Oct 7, 2010

I have a script in which I'm reading a file line by line and I'm finding certain position value using awk index as

Code:
# 2 spaces before open parens
pos=`echo | awk -v Line="$Line" '{ print index("'"$Line"'"," (")}'`

[code]....

View 2 Replies View Related

Programming :: Variable Substitution In BASH?

Feb 17, 2011

Just a simple BASH for loop to read the file path from a text file (clean.txt) echo the variable for debug purposes, and scp it to a server I have using port 50 for SSH.

I've already formatted the entries in clean.txt to handle spaces correctly, using sed replacement.

Example from the clean.txt file:

Code:
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/20 Auld Lang Syne.mp3
/MP3/NAS000000001/Barenaked Ladies/Barenaked Ladies - Barenaked For The Holidays/14 Deck the Stills.mp3

[Code]....

View 5 Replies View Related

Programming :: SH - Recursive Variable Substitution

Jul 1, 2010

I have the following test code fragment:

Code:

When I try to run it 'sh' reports the following message^

Code:

You might understand what I mean with that test code so could you recommend how to achieve the required effect?

View 7 Replies View Related

Programming :: Implement Variable Substitution In Strings?

May 6, 2011

I have an interpteter that supports string literals, and the way it works is that the lexer returns the entire string as a single token, with the quotes removed and escape sequences replaced with the literal characters they represent.

I already implemented single-quote strings, they don't interpret any characters specially except for the single quote. I partially implemented double-quoted strings, they already support all the same backslash escape sequences that C does. But I would also want to add variable substitution.

The way it would work is that "${expression}" would interpret the expression (which could just be a variable name) and replace itself with the result. But I have no idea how to do this.

In case it matters, I'm using a hand-written lexer and recursive-descent parser.

View 14 Replies View Related

Programming :: Variable Substitution In Sqlite Open Db Command?

Jun 15, 2010

I have the following TCL code:

if{ [catch {sqlite3 db /path/to/db/file} result] } {
puts stderr $result
} else {
do something
}

What I want is to use a variable for the file name/path. When I put in a variable instead of the absolute path, I get an error: "missing close-brace: possible unbalanced brace in comment while executing"

This is weird because when I run the code with the fully qualified pathname, it works fine. I substitute out the pathname for a variable containing the pathname ($variable) and I get this error.

View 1 Replies View Related

General :: Assign Local Variable Values To Global Variable?

Feb 17, 2011

how to assign a local variable value to a global variable....

View 2 Replies View Related

General :: Create An Environment Variable With The PRINTER Variable?

Apr 16, 2011

I am supposed to create an environment variable with the PRINTER variable, which should resolve to the word sales. Would the command be like this?: env PRINTER - NAME=SALES (is this the command to create that variable with resolving the word sales to it?)

View 3 Replies View Related

General :: Use The Value Of One Variable To Generate A Name For Another Variable?

Jul 25, 2010

can i use the value of one variable to generate a name for another variable? for example i want to use the counter from a "do while" loop to name and define a variable each time the loop executes. for example

objectnames1=`ls -a`
objectnames2=`ls -a`
etc.

i don't have a script yet but each time through the loop i intend to cd to a particular directory and then define a variable containing a list of each object in that directory as values. for the rest of the script to work, each variable generated has to be unique, and i can't think of a good way to accomplish this.

if using a value from one variable to name another isn't possible, can anyone think of a more elegant solution? i know limited syntax but i'm willing to read up...

View 6 Replies View Related

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

Programming :: Make A New Variable With The String From The Old Variable Btut Without Any Plus Sign?

Apr 7, 2010

my script has a variable which comes in the form +00.00 +0.00 -00.00 or -0.00 (the numbers can be any in that form) for any that have a + symbol I need to remove the +, but if it has a - symbol it needs to stay.

i need to make a new variable with the string from the old variable btut without any plus sign. I have tried a lot of different ways with no success, each thing I tried either left the + or removed the entire string. I think this should work but doesn't

foo=+12.40
bar=${foo#+}

View 4 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

Programming :: Search Within A Variable And Assign The Results To A New Variable?

Apr 25, 2011

how I can search within a variable and assign the results to a new variable. I'll use the following as an example -

cars="Audi BMW Cadillac Chevy Dodge Ferrari Ford Mercedes"
list=`echo ${cars} | egrep -o '<A?+|<C+'`

with the echo command I get the following output assigned to list -

A
C
C

What I'd like to get for output is -

Audi
Cadillac
Chevy

how I could do this regardless of upper/lower case letters?

View 5 Replies View Related

Programming :: Assign Value Of C Variable To Shell Variable?

Apr 28, 2010

included shell script inside c program, and i wanted to assign the value of c variable to shell variable..Can any one please suggest me how to do it?

View 8 Replies View Related

Programming :: Assignment To A Variable Variable?

Mar 17, 2011

This loop is part of a bash script which takes multiple arguments.

Code:
for ((i=1;i<=$number;++i)) ; do
offset=$(($i+5))

[code]...

View 3 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 :: How To Set The Path Variable

Jan 14, 2010

By mistake I have modified the PATH variable you know what a kind of mess it is.

Code:
echo $PATH

I just need to set the path variable again so I just need the format. Or can anybody come up with how to set the path variable.

View 6 Replies View Related

General :: Getting Sub-string In A Variable

Jul 13, 2010

I'm facing problems in developing the script as there are errors that sometimes i dun have any idea on how to solve it.What i'm doing now is not homework, but i had been assigned to develop some system in linux.

My problem currently is on sub-string matter, where i need to read the line from file/directory and based on the line retrieved,i need to seperate the information in the line and assign as variable..

Below are my script:

Thus, the output something like this: file_name successfully ran on Mon Jul 12 23:15:00 SST 2009.

Now, what i need to do is to extract certain information from that line which is the name, date, time and the status

The desired output is:

So,my next step is to identify the sub-string and assigned as variable first in order to parse the info and output it.

Thus,my script is:

But i received error message which is:

View 14 Replies View Related

General :: Passing One Variable To Another

Jan 8, 2011

I am new to bash scripting. I want to know whether i can pass one variable to another. For example $1 represent argument1. Now if i want to get the argument 1 like USER="1" now i want $ of $USER to execute $1 so what should i do..

View 2 Replies View Related

General :: Where Is The $HOME Environment Variable Set

Apr 17, 2011

I'm looking for the place where $HOME environment variable set. It is after login, to my mind.

I'm using Linux debian 2.6.32-5-686.

View 3 Replies View Related

General :: How To Change The PATH Variable

Mar 12, 2011

I was changing my sudoers file to give permission of using "sudo" command to all root commands, asking for the password. It works, it's fine. The problem I'm having is with the variable PATH to my user, I think.

In terminal:
normal user:

Code:

ataias@ataias-notebook:~/Downloads$ echo $PATH
/usr/local/bin:/bin:/usr/bin
super user:

Code:

root@ataias-notebook:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/usr/sbin:/bin:/usr/bin

As many commands are in /sbin/, root can use them without writing "/sbin/" but I can't do the same cause it's not in my path.

while root do this:

Code:

shutdown -h now

I should do:

Code:

sudo /sbin/shutdown -h now

and I want to use only

Code:

sudo shutdown -h now

I want to change my user's path variable to make it equal to root's path. how to change it? I don't know many things of shell still.

View 5 Replies View Related

General :: SH Script Not Evaluating Variable?

Jun 21, 2010

I am trying to evaluate the variable HEADER to see if it contains "HTTP/1.1 200 OK" and if so, to do something. If not, do something else. (writing to files - see below).The variable is being set, as ALL of the URLs that I am evaluating are being put into bad_urls.txt with their response headers. I can't figure out what I'm doing wrong. I've tried modifying the line in question quite a bit, trying different things, including:

if [[ ${HEADER} =~ "HTTP/1.1 200 OK" ]]; then
if [[ ${HEADER} == "HTTP/1.1 200 OK" ]]; then
if [[ HEADER = "HTTP/1.1 200 OK" ]]; then

[code]...

View 5 Replies View Related

General :: Using Variable To Run An Executable File?

May 27, 2010

I have an executanle file in a directory (say /home/mahmood/test/do-sample) and in a bash file I want to run it:

Code:
#!/bin/bash
M_VARIABLE = $HOME/test

[code]...

View 3 Replies View Related

General :: Awk Does Not Print The Value Of The Variable As Expected

Apr 4, 2011

I have this simple awk program but it not prints var_cab whe^E or ^S or ^M after he finds the second ^C

/^C/ { var_cab = substr($0,1,28); ent = 0 ; print "estoy en cabecera" var_cab;}
/^E/ { if ( ent ==0 ) var_fech = substr($0,4,8) ; ent ++;
print var_cab var_fech $0; }
/^S/ { print var_cab var_fech $0; }
/^M/ { print var_cab var_fech $0; }
END { print var_cab,ent}

the input file is many lines like this, every new block stats with ^CAB

CABES3000088888880000007EAMB
ENT20090706D060709-888 0028560000000012VALLE CA'ZULIA5501, 5502, 5498 y 5535
SAL201008250000134900000321V1202935-MU

[code]....

View 4 Replies View Related

General :: Awk - Convert Variable To String?

Nov 15, 2010

How do i convert variable to string?

For example:

So how do i make the code with variable work?

View 7 Replies View Related

General :: Change PATH Variable

Oct 16, 2010

I want to add my current working directory to the PATH variable and make it permanant in my .bash_profile so I can run my testscript without using the ./ charactors.can this be done?

View 5 Replies View Related

General :: Exporting A Variable From Within .xsession?

Mar 31, 2011

I'm trying to export a variable from within the .xsession so it will be available to any application started afterwards.

Here is a minimial .xsession file:

Code:

export MYVAR=123
exec gnome-session

The problem is that when I start a terminal and do:

Code:

echo $MYVAR

I get an empty string, meaning it's undefined.

View 2 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 :: PATH Variable Setup?

Jan 22, 2010

One of my colleague ran into trouble with setting up of path variable.

Earlier the entry for PATH in /etc/profile was:

Code:

Now what he mistake is:

He added a new Lines at the end as

Code:

Now due to this he is unable to run commmands now because that has overwritten the earlier PATH varaible.
If he types now:

It shows:

Code:

View 7 Replies View Related

General :: Pass A Variable From One Script To Another?

Nov 22, 2009

I want to pass a variable from one script to another, I have a feeling it's extremely simple.

I looked at exporting, but apparently that clogs up the shell, so I don't want to go down that route. Any suggestions?

View 2 Replies View Related







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