07-24-2003
String Substitution Question
When I run the script I pass in 2 expressions (ex. replace.ksh new old)
I want the script to go line by line for a given file in a given directory and replace the word new with old. Of course in my line where I have the awk statement it is replacing the 2nd word with 1st instead of new with old. The only caveat to this is that this script will be replacing directory structures. We want to go from a development dir to a production dir and make the change to every file within a directory.
Any help with this would be very much appreciated.
for FILE in `ls`
do
while read LINE
do
echo $LINE | grep -q $1
if [ $? -eq 0 ]
then
# print $1 ${1} $2 ${2}
# val=$1 chval=$2
echo $LINE | awk '{sub($1,$2);print}' >> ${FILE}_new
else
echo $LINE >> ${FILE}_new
fi
done < $FILE
# mv TMP_00 $FILE
# rm TMP_00
done
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi!
I've the following script code with an input parameter:
sed 's/oldstring/$1/g' myfile > newfile
(I launch it with comman line: $ MyShell newstring)
Problem: the substituion doesn't work (oldstring becomes $1, instead of newstring). How could I solve this situation?
Thanks, ... (2 Replies)
Discussion started by: pciatto
2 Replies
2. Shell Programming and Scripting
Hello
I have several files where a string similar to this appears:
/home/workload/bin/ProcDly/scrpts/T54.sh > $LOG
I need to change it to something like this:
$VARIABLE > $LOG
However, due to the configuration of the rest of the files, I should only find this string by the... (4 Replies)
Discussion started by: Scarlos
4 Replies
3. UNIX for Advanced & Expert Users
Hey ppl,
Could u tell me how to replace such a string
xyz->x with XYZ(x), where x can be any variable accessible by pointer to structure, xyz
in an entire file? (1 Reply)
Discussion started by: laxmi
1 Replies
4. Shell Programming and Scripting
Hey ppl,
Could u tell me how to replace such a string
xyz->x with XYZ(x), where x can be any variable accessible by pointer to structure, xyz
in an entire file? (3 Replies)
Discussion started by: laxmi
3 Replies
5. Shell Programming and Scripting
Hi,
I have a properties file (myprop.properties) which contains some values:
@oneValue@==tcp://localhost:1234
@twoValue@==tcp://localhost:4563
@threeValue@==tcp://localhost7895
I have a xml file (myXmlFile.xml)which contains some tokens:
<application name="aTest">
<NameValuePair>
... (3 Replies)
Discussion started by: ctrl-alt-del
3 Replies
6. Shell Programming and Scripting
Hi friends!
I have a tab delimited file with two columns :
GB_45_DRB SP:0139466(mrmi sisignm)|SP:3674(fllflg_itoioh)|SP:68954779(RMTKLGF to emmdm-roomto)
GB_45_DRD SP:475928(mgmdksi rikgkg)|SP:587959(roykgl tiic-tm)|SP:0139466(mrmi sisignm)|SP:3674(fllflg_itoioh)|SP:68954779(RMTKLGF to... (4 Replies)
Discussion started by: jacks
4 Replies
7. Shell Programming and Scripting
hi guys...need some help here...
i am making a a script to automatically install netbackup client...so its gonna write a configuration file according to the host name.... the line would be something like this
CLIENT_NAME = odel_bkp.test.com
the thing is ...the host name in reallity is... (2 Replies)
Discussion started by: razael
2 Replies
8. Shell Programming and Scripting
Hi,
I have a template file and want to replace 3 parameters to the values that I want. these values are in a parameter file.
Any idea how to do this in perl?
the parameter file looks like:
host_name = jupiter
PORT = 1562
IPADDRESS = 10.1.34.10
the template file has lots of entry.... (1 Reply)
Discussion started by: melanie_pfefer
1 Replies
9. Shell Programming and Scripting
I have the following code:
strfuture=abcdefghi
ver=${strfuture:${count}:1}
mj7777_ver=${ver} start_mj7777_iteration
let count=count+1
When it is executed I get bad substitution. The same if I use
ver=${strfuture:$count:1}
mj7777_ver=${ver}... (6 Replies)
Discussion started by: Bruble
6 Replies
10. Programming
We have a formatted screen system where a driver program passes the locations of a list of files that called programs may be using. It will look something like this:
/{number of characters varies}/DATA/MASTERFILEBecause of the size of some files we will be splitting older records into a history... (2 Replies)
Discussion started by: wbport
2 Replies
LEARN ABOUT DEBIAN
netbeans
NETBEANS(1) Java IDE and More NETBEANS(1)
NAME
NetBeans - Java IDE
SYNOPSIS
netbeans [ options ] [ files ]
PARAMETERS
options
Command-line options.
files
Files to be opened in NetBeans IDE.
DESCRIPTION
NetBeans is a cross-platform IDE written in Java. It supports development in Java, and support for other languages can be added. The whole
IDE is built around a core framework with APIs, and features are implemented in the form of plugin modules. This clean, modular architec-
ture makes NetBeans a good platform for building development tools and custom IDEs.
OPTIONS
General options:
--help
List available command line options
--jdkhome <path>
Path to JDK home used to run IDE
-J<jvm_option>
Pass <jvm_option> to JVM
--cp:p <classpath>
Prepend <classpath> to classpath
--cp:a <classpath>
Append <classpath> to classpath
Core options:
--laf <LaF classname>
Use given LookAndFeel class instead of the default
--fontsize <size>
Set the base font size of the user interface, in points
--locale <language[:country[:variant]]>
Use specified locale
--userdir <path>
Use specified directory to store user settings
Module reload options:
--reload /path/to/module.jar
Installs or reinstalls a module JAR file.
OpenFile module options:
--open FILE
Open FILE.
--open FILE:LINE
Open FILE at line LINE (starting from 1).
AUTHOR
NetBeans was written by the NetBeans Community <http://www.netbeans.org/>.
This manual page was written by Marek Slama <mslama@netbeans.org>, for the Debian project (but may be used by others).
January 18, 2008 NETBEANS(1)