Sponsored Content
Top Forums Shell Programming and Scripting Bash-how to properly READ and PASTE variables. Post 302575376 by arisinhell on Monday 21st of November 2011 12:22:59 PM
Old 11-21-2011
Bash-how to properly READ and PASTE variables.

Recently i made a script for a project at molecular dynamics but am stuck at the last step.The thing i want to do is to ask the user to input the number of particles, then replace the bolded numbers at lines 9 and 17..

code

Code:
#!/bin/bash
#read number of particles
echo "insert the number of particles"
read particles
#convert text
#mv coordinates.txt coordinates
#main.in manipulation
#insert number of particles
sed 's/.*input_coord.*/particle 936  #input_coord/g' main.in > main.tmp; mv main.tmp main.in
#remove old coordinates
grep -Ev '#______' main.in  > main.tmp; mv main.tmp main.in
#add new coordinates
sed '/input_coord/ r coordinates' main.in > main.tmp; mv main.tmp main.in
#acf.f manipulation
#add number of particles
sed '3s/.*/      DATA ITM\/1000\/,IM\/936\//' acf.f > acf.tmp; mv acf.tmp acf.f
#xmd
../xmd/src/xmd main.in > timelog.out
#compile acf.f
..
blah
blah


I tried something like this
Code:
read particles
..
sed 's/.*input_coord.*/particle ${particles}  #input_coord/g' main.in >
or
sed 's/.*input_coord.*/particle $particles  #input_coord/g' main.in >

but still nothing..




Thank you in advanceSmilie

Last edited by pludi; 11-21-2011 at 03:48 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

I can't seem to pass variables properly into a nawk statement

Ok, So up front I'm going to say that I'm a very elementary scripter, and I tend to use tools I don't fully understand, but I shotgun at something until I can get it to work...that said, I can't for the life of me understand why I can't get this to go down the way I want it to. The goal: -to... (6 Replies)
Discussion started by: DeCoTwc
6 Replies

2. Shell Programming and Scripting

arrays not printing properly in bash

hi guys, i wrote this script and it takes some fields from a file and puts it into three different arrays. The first array works just fine but when I try to use the second array (ARRAY1) all i get is a blank value on the screen.. this works fine..i get ARRAY value on the screen just fine ... (1 Reply)
Discussion started by: npatwardhan
1 Replies

3. Shell Programming and Scripting

command paste with variables

Hi. I have an interesting problem and i couldn't find out the solution. I have two variables in which there are a lot of lines finished by \n. I would like to concatenate this two variables into one in this format: var1var2 var1var2 . . . I could do this simply by command paste but it works... (32 Replies)
Discussion started by: samos
32 Replies

4. Shell Programming and Scripting

read file column and paste it in command

Hi Unix gurus I have a file containing 2 coloumns. I would like to do a script which reads the lines and executes a command like this: command <field1> parameters <field2> some more parameters Please let me know how you would do this without AWK, SED or any other mini language (for special... (5 Replies)
Discussion started by: BearCheese
5 Replies

5. Shell Programming and Scripting

Need helpl in scripting read 2 lines and paste to one single line.

Hi All, I need to create script which will accept one file as i/p and give me o/p file described as below. 1) i/p log file named abc.log contents several lines but i am interested in lines like below. #FILE..... /oracle/XYZ/sapdata1/undo_7/undo.data7 #SAVED.... BACKINTID001 2) o/p... (4 Replies)
Discussion started by: paragp1981
4 Replies

6. Shell Programming and Scripting

Bash script to read a hostname and separate into variables

Hi All, I'm trying to concoct a bash script to use with a Puppet Implementation that will accept a hostname and break it down into variables. For example, my hostnames look like this --> machinename-group-building.example.com I'm looking for a way in the script to read until the first... (4 Replies)
Discussion started by: glarizza
4 Replies

7. Shell Programming and Scripting

echo two variables like the paste command is not working

Dear all, I have two files like this file1 A B C D E F file2 1,2 3,4 5,6 I want this output output_expected A B 1,2 C D 3,4 E F 5,6 (3 Replies)
Discussion started by: valente
3 Replies

8. Shell Programming and Scripting

Need help with paste command using variables

How can I accomplish this? I basically want to merge two variables onto the same line. I can do it with two FILES this way: $ cat /tmp/users_in.list | awk -F "," '{print $2}' | cut -c -1 > first.initial $ awk -F "," '{print $1}' /tmp/users_in.list | awk '{print $1}' > last.name $ paste... (5 Replies)
Discussion started by: greenlightening
5 Replies

9. Shell Programming and Scripting

How to paste properly?

I needed to view calendar for several months so I created a separate file for each and then pasted them like this: cal Dec 2011 > x1; cal Jan 2012 > x2; paste x1 x2 December 2011 January 2012 Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa 1 2 3 1 2 ... (4 Replies)
Discussion started by: migurus
4 Replies

10. Shell Programming and Scripting

Beginner here, how to call a bash-script from python properly?

Hi everyone, i have the following script.sh: foo='lsusb | grep Webcam | cut -c16-18' sudo /home/user/public/usbreset /dev/bus/usb/001/$foo when i try to call this script from python using subprocess.call("script.sh", shell=True) it seems that only 'sudo /home/user/public/usbreset' is being... (6 Replies)
Discussion started by: hilfemir
6 Replies
MEGAGLEST_G3DVIEWER(6)						       Games						    MEGAGLEST_G3DVIEWER(6)

NAME
megaglest_g3dviewer - G3D Model editor for the popular 3D realtime stragegy game DESCRIPTION
megaglest_g3dviewer v1.3.6, [Using wxWidgets 2.8.12] usage: megaglest_g3dviewer [G3D FILE] Displays glest 3D-models and unit/projectile/splash particle systems. rotate with left mouse button, zoom with right mouse button or mousewheel. Use ctrl to load more than one particle system. Press R to restart particles, this also reloads all files if they are changed. optionally you may use any of the following: Parameter: Description: ---------------------- ------------ --help displays this help text. --load-unit=x Auto load the unit / skill information specified in path/filename x Where x is a g3d filename to load separated with a comma and one or more skill names to try loading: example: megaglest_g3dviewer --load-unit=techs/megapack/factions/tech/units/battle_machine,attack_skill,stop_skill --load-model=x Auto load the model specified in path/filename x Where x is a g3d filename to load: example: megaglest_g3dviewer --load-model=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d --load-model-animation-value=x Animation value when loading a model Where x is a decimal value from -1.0 to 1.0: example: megaglest_g3dviewer --load-model-animation-value=0.5 --auto-screenshot=x Automatically takes a screenshot of the items you are loading. Where x is a comma-delimited list of one or more of the optional settings: transparent, enable_grid, enable_wireframe, enable_normals, disable_grid, disable_wireframe, disable_normals, saveas-<filename>, resize-wxh example: megaglest_g3dviewer --auto-screenshot=transparent,disable_grid,saveas-test.png,resize-800x600 --load-model=techs/megapack/fac- tions/tech/units/battle_machine/models/battle_machine_dying.g3d --load-particle=x Auto load the particle specified in path/filename x Where x is a Particle XML filename to load: example: megaglest_g3dviewer --load-particle=techs/megapack/factions/persian/units/genie/glow_particles.xml --load-projectile-particle=x Auto load the projectile particle specified in path/filename x Where x is a Projectile Particle Definition XML filename to load: example: megaglest_g3dviewer --load-projectile-particle=techs/megapack/factions/persian/units/genie/particle_proj.xml --load-splash-particle=x Auto load the splash particle specified in path/filename x Where x is a Splash Particle Definition XML filename to load: example: megaglest_g3dviewer --load-splash-particle=techs/megapack/factions/persian/units/genie/particle_splash.xml --load-particle-loop-value=x Particle loop value when loading one or more particles Where x is an integer value from 1 to particle count: example: megaglest_g3dviewer --load-particle-loop-value=25 --zoom-value=x Zoom value when loading a model Where x is a decimal value from 0.1 to 10.0: example: megaglest_g3dviewer --zoom-value=4.2 --rotate-x-value=x X Coordinate Rotation value when loading a model Where x is a decimal value from -10.0 to 10.0: example: megaglest_g3dviewer --rotate-x-value=2.2 --rotate-y-value=x Y Coordinate Rotation value when loading a model Where x is a decimal value from -10.0 to 10.0: example: megaglest_g3dviewer --rotate-y-value=2.2 --screenshot-format=x Specify which image format to use for screenshots. Where x is one of the following supported formats png,jpg,tga,bmp *NOTE: png is the default (and supports transparency) example: megaglest_g3dviewer --screenshot-format=jpg Invalid argument: --version megaglest_g3dviewer v1.3.6, [Using wxWidgets 2.8.12] usage: megaglest_g3dviewer [G3D FILE] Displays glest 3D-models and unit/projectile/splash particle systems. rotate with left mouse button, zoom with right mouse button or mousewheel. Use ctrl to load more than one particle system. Press R to restart particles, this also reloads all files if they are changed. optionally you may use any of the following: Parameter: Description: ---------------------- ------------ --help displays this help text. --load-unit=x Auto load the unit / skill information specified in path/filename x Where x is a g3d filename to load separated with a comma and one or more skill names to try loading: example: megaglest_g3dviewer --load-unit=techs/megapack/factions/tech/units/battle_machine,attack_skill,stop_skill --load-model=x Auto load the model specified in path/filename x Where x is a g3d filename to load: example: megaglest_g3dviewer --load-model=techs/megapack/factions/tech/units/battle_machine/models/battle_machine_dying.g3d --load-model-animation-value=x Animation value when loading a model Where x is a decimal value from -1.0 to 1.0: example: megaglest_g3dviewer --load-model-animation-value=0.5 --auto-screenshot=x Automatically takes a screenshot of the items you are loading. Where x is a comma-delimited list of one or more of the optional settings: transparent, enable_grid, enable_wireframe, enable_normals, disable_grid, disable_wireframe, disable_normals, saveas-<filename>, resize-wxh example: megaglest_g3dviewer --auto-screenshot=transparent,disable_grid,saveas-test.png,resize-800x600 --load-model=techs/megapack/fac- tions/tech/units/battle_machine/models/battle_machine_dying.g3d --load-particle=x Auto load the particle specified in path/filename x Where x is a Particle XML filename to load: example: megaglest_g3dviewer --load-particle=techs/megapack/factions/persian/units/genie/glow_particles.xml --load-projectile-particle=x Auto load the projectile particle specified in path/filename x Where x is a Projectile Particle Definition XML filename to load: example: megaglest_g3dviewer --load-projectile-particle=techs/megapack/factions/persian/units/genie/particle_proj.xml --load-splash-particle=x Auto load the splash particle specified in path/filename x Where x is a Splash Particle Definition XML filename to load: example: megaglest_g3dviewer --load-splash-particle=techs/megapack/factions/persian/units/genie/particle_splash.xml --load-particle-loop-value=x Particle loop value when loading one or more particles Where x is an integer value from 1 to particle count: example: megaglest_g3dviewer --load-particle-loop-value=25 --zoom-value=x Zoom value when loading a model Where x is a decimal value from 0.1 to 10.0: example: megaglest_g3dviewer --zoom-value=4.2 --rotate-x-value=x X Coordinate Rotation value when loading a model Where x is a decimal value from -10.0 to 10.0: example: megaglest_g3dviewer --rotate-x-value=2.2 --rotate-y-value=x Y Coordinate Rotation value when loading a model Where x is a decimal value from -10.0 to 10.0: example: megaglest_g3dviewer --rotate-y-value=2.2 --screenshot-format=x Specify which image format to use for screenshots. Where x is one of the following supported formats png,jpg,tga,bmp *NOTE: png is the default (and supports transparency) example: megaglest_g3dviewer --screenshot-format=jpg megaglest_g3dviewer October 2012 MEGAGLEST_G3DVIEWER(6)
All times are GMT -4. The time now is 09:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy