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)
So, I have 100 folders each of them include a file called script.txt and script2.txt. the file script.txt has and 100include files that have the same name like the folders. So, for example if I have the folders A, B and C then the script.txt will include 3lines such as:
*include A *include B *include C
I want for each folder (A, B and C) to create script2.txt which will substitute *include A with $include A, respectively for each folder.
so for folder A, I will have script2.txt
$include A *include B *include C
[Code].....
but it is substituting "*" with "$" in each file for all the lines. I think i should probably close earlier a loop.
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
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.
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.
Code: SERVERS=(SERVER1 SERVER2 SERVER3) SERVER1_SERV=(web ftp mail) SERVER2_SERV=(web transcoding) SERVER3_SERV=(web ftp mail) for SERVER in ${SERVERS[@]} do echo "Starting tranfer for server $SERVER" for SERVICE in ${$SERVER_$SERVICE[@]} do something_to_be_done fi done But when I run it I get ${$SERVER_$SERVICE[@]}: bad substitution
I am using Red Hat Linux Enterprise 5. I know the theory that -- using export to set environment variable, the environment variable will apply to current and child environment, but without using export to set environment variable, the environment variable will only apply to the current environment. What is the exact definition of "child environment" and "current environment"? For example,
Code: $ var1=123 $ echo "Hello [$var1]" The value of var1 (which is 123) is printed in shell, but I think echo is a command invoked by current shell, and it (the echo command) should be a child environment of current shell and the value of var1 should not (because not using export var1=123) impact echo.
We have a file that declares many environmental variables. Out of which I have doubt on few. These variables are declared in UNIX environment. We are planing to migrate them along with applications to Linux.
Code: export MAILSERVER="%new@hub" MAIL_USERS="vinay.new"{MAILSERVER}",vijay.new"{MAILSERVER} Does the above declarations work in Linux ? The above declarations expands to Code: mail vinay.new%new@hub,vijay.new%new@hub which looks little wierd.
I heard (although I can't find any sources for proof) that the USER environment variable may not be set in a old Unix shells (maybe even some obscure shells as well). What is the probability that it won't be set?
I have created a shell script to customise mv command, now i have achieved to accomplish all the functionality of mv by using alias. But i found difficulty in accomplish the funcionality with options [Like mv -i or mv -f etc.]. I thought about logic which check the first argument whether its starting with a minus [-] or not. if its starting with argument it will set a flag and execute accordingly. But whenever this condition is checked it shell script will throw error of destination operand missing. But the same will work with out option.
Note: I have used an minus[-] expression for decreasing a counter on the script above. The below mentioned is the portion of script. Sry for troubling Im not gud @scripting.
for i in $* do { argument=`expr $argument - 1` if [ $argument = 0 ]; then exit [Code]....
Using things like awk/sed, but have managed to cobble together what I needed so far without a problem. The only thing I'm struggling with is to assign the content of a particular line as a variable, and then to use it again throughout the file.
For example, if what I want is the first line of the file to become the variable "from1", and then to replace the word "Subject" in the file with the string "Message from [from1]". What I thought would work
I tried a few diff combinations but nothing seems to work. All I get is the terminal hanging indefinitely.
I have a application on linux , I can excute it in command line . but when I invoked it via CGI(perl) , it can not excute successfully , so I suspected that there is something different between SHELL and CGI environment , but I haven't figure out what the difference is .
I have some messy code that I wrote a while back and I am trying to organize it. The program opens xpaint and uses xwit and xte to draw packman and so on. I want to split it all up I am going to add more to it. Basically like i would want drawing packman in one function i guess you could call it and then coloring him or the background in another
#xwit -id $paintersMom -focus -raise #sleep 1 #xwit -id $paintersMom -warp 30 390 #// fill in command on tool bar #sleep 1 #xte 'mouseclick 1' #sleep 1 #xwit -id $canvasWin -warp 221 40 #// color selection #sleep 1 #xte 'mouseclick 1' #sleep 1 #xwit -id $canvasWin -warp "$(($X-150))" "$Y" #//location on pac man #sleep 1 #xte 'mouseclick 1' #sleep 1
#xwit -id $canvasWin -warp 62 44 #// selecting color black #sleep 1 #xte 'mouseclick 1' #sleep 1 #xwit -root -warp 62 120 #// selecting back to canvas #sleep 1 #xte 'mouseclick 1' #// color canvas black #sleep 1 #xwit -id $paintersMom -focus -raise #xwit -id $paintersMom -warp 27 108 #//click back to pencil #sleep 1 #xte 'mouseclick 1' #sleep 1 </code>
Here for example $paintersmom is would be in the drawing of pacman but I would also want to use it when I colored him in.. but I would want both processes in a different shell script.
What I am trying to accomplish is a way to read only the lines that have been added to the file mylog0 since the last time the script looped (5 seconds). I am open to new suggestions too, I have been stuck on this little script for a few hours already.
I need to be able to set a variable that is used by my build environment. I need to be able to change this variable "on the fly" as I work with multiple build environments. A portion of the variable is arbitrary, so I need to treat the arbitrary portion of the variable as an argument.
I would normally just create an alias, but BASH doesn't support arguments to aliases. So the workaround for the no-alias-arguments bug is to use a script. No problem. Except the variable I set in the script does not exist when I exit the script.Now, if I run the script by using "$ . myscript" it works in that the variable is set after it exits. The problem is the argument checking I have in the script doesn't work anymore. BASH aliases don't support arguments and I can't export a variable from a script unless I source the script (is it even a script at that point?) Maybe I am simply taking the wrong approach.
The above command does exactly what I want: limit the search of files in $SEARCHDIR to those specified by --include.
I use double quotes rather than single quotes because of the shell variables. I would have thought this would cause the shell to expand the "*" but this doesn't seem to be the case.
I'm using sed to remove certain line in a text file based on a match with 2 variables from input. Here is how it looks like in file
Philip S:Odds:45:343 Mike Junior:Odds:3:56
I prompt for 2 inputs in variable form which is compared to the first 2 fields of the above text (: seperated). So say i enter Philip S and Odds then it should delete the entire first line.