Sponsored Content
Top Forums Shell Programming and Scripting replacing variable values in all files in directories Post 94378 by Just Ice on Friday 30th of December 2005 01:48:33 AM
Old 12-30-2005
just a quick point on matrix's script ... the files with the variables being replaced are most likely executable scripts --- you might not want to use "mv temp $file" as that would change the permissions on $file to the default permissions on temp which means most likely 644 ... use "cat temp > $file" instead ...
Code:
#! /usr/bin/ksh

for file in `find . -name '*' | xargs grep -il 'A = 10'`
do
sed -e 's/A = 10/A = 20/g' $file > temp
cat temp > $file
rm temp
echo "File $file done"
done

exit 0

btw, unless you're scripting in csh/tcsh --- there should be no spaces in between the variable name, the equal sign, and the variable value (i.e., A=10 instead of A = 10) ...
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Replacing File values

Currently I am using the tr command in 3 scenarios for a ksh script. 1) Replacing any spaces in the file with a ~ tr ' ' '~' <$orignalFile> $newFile 2) After certain processing is done at the end of the scirpt i convert the Tilde back to spaces tr ' ' '~' <$newFile> $newFile2 3) Last... (4 Replies)
Discussion started by: hgjdv
4 Replies

2. UNIX for Dummies Questions & Answers

List directories and sub directories recursively excluding files

Hi, Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process. I wanted to disply using a unix command all the directories recursively excluding files. I tried 'ls -FR' but that display files as... (3 Replies)
Discussion started by: pointers
3 Replies

3. Shell Programming and Scripting

Replacing variable values in html tags

Hi please help me with this . I have a file test.txt with following content $cat test.txt <td>$test</td> <h2>$test2</h2> and I have a ksh with following content $cat test.ksh #!/bin/ksh test=3 test2=4 while read line do echo $line done < test.html I am expecting the output as (4 Replies)
Discussion started by: panduandpavan
4 Replies

4. Shell Programming and Scripting

Replacing variable is files in same directory

Hi all, I'm writing a script to get values from the user and replace it in another file in the same directory. /usr/bin/sediff 's/$PROJECT/'$PROJECT'/' /ananth/TEMPLATE TEMPLATE is the file I want to replace the variable PROJECT from the script I'm writing but Im not getting it done. Is... (4 Replies)
Discussion started by: Ananthdoss
4 Replies

5. Shell Programming and Scripting

Replacing column values

hi all , ( perl) i am trying to replace jst one column in a file for eg month dayofweek dealar car-name jan thurs mercedes c300 feb wed lexus is300 all this data is in a master file and i want to replace jan with 1 feb... (5 Replies)
Discussion started by: technoman
5 Replies

6. Shell Programming and Scripting

How to list all the files, directories and sub-directories in the current path except one directory?

Can anyone come up with a unix command that lists all the files, directories and sub-directories in the current directory except a folder called log.? Thank you in advance. (7 Replies)
Discussion started by: Manjunath B
7 Replies

7. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

8. Shell Programming and Scripting

Archiving and moving files into directories, creating directories, etc.

how can i move "dataName".sql.gz into a folder called 'database' and then move "$fileName".tar.gz * .htaccess into a folder called 'www' with the entire gzipped file being "$fileName".tar.gz? Is this doable or overly complex. so mydemo--2015-03-23-1500.tar.gz > database -... (5 Replies)
Discussion started by: wyclef
5 Replies

9. UNIX for Dummies Questions & Answers

Help in replacing column values

Hello All, I am having the file as below .I need to replace column 9-12 with some other values. In the below file I need to replace 1509 to 1508 and 1508 to 1507 .Can you please help me in how to do that Thanks, Arun ... (10 Replies)
Discussion started by: arunkumar_mca
10 Replies
RINGS3D(1)						      General Commands Manual							RINGS3D(1)

NAME
rigns3d - produces a file of ring-filling triangles from a PDB file SYNOPSIS
rings3d [-bases] [-protein] [-sugars] < infile.pdb > outfile.r3d rings3d searches through a PDB file looking for residues containing 5- or 6-membered rings, then produces a Raster3D output file of ring- filling triangles. rings3d matches residue types from an internal list of residue and atom names. It will fail to find residues not in its list, and fail to recognize atoms with non-standard names. EXAMPLES
render a DNA molecule with the bases filled in: cat $R3D_LIB/dna.colours dna.pdb | rods -radius 0.05 > temp.1 rings3d -bases < dna.pdb > temp.2 cat temp.1 temp.2 | render -tiff dna.tiff OPTIONS
-bases Fills in purine and pyrimidine rings from A C G T U residues. -protein Fills in sidechain rings of HIS PHE TRP and TYR residues. -sugars [This is the default] Fills in pyranose rings of GAL GLC NAG NGA MAN SIA residues. BUGS
limited residue types The database of residue types should be kept externally, so you don't have to rebuild the program to add a new type. There should be an option to search for ring systems in un-recognized residue types. crinkled planes There should be an option to do a least-squares best plane through supposedly flat rings. Then again, seeing a crease in a "flat" ring may force people to consider whether their planarity restraints are tight enough. SOURCE
anonymous ftp site: ftp.bmsc.washington.edu web URL: http://www.bmsc.washington.edu/raster3d/raster3d.html contact: Ethan A Merritt Dept of Biological Structure Box 357742 University of Washington, Seattle WA 98195 merritt@u.washington.edu SEE ALSO
Raster3D(l) AUTHORS
Ethan A Merritt. This manual page was written by Nelson A. de Oliveira <naoliv@gmail.com>, for the Debian project (but may be used by others). Raster3D RINGS3D(1)
All times are GMT -4. The time now is 11:47 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy