12-11-2003
improving my script (find & replace)
Hi all,
I have a script that scan files, find old templet and replace it with new one.
#!/bin/ksh
file_name=$1
old_templet=$2
new_templet=$3
# Loop through every file like this
for file in file_name
do
cat $file | sed "s/old_templet/new_templet/g" > $file.new
#do a global searce and replace and put the results
mv $file.new $file
#rename $file.new to original name of file
done
How can I replace the old templet with few rows templet ?
for example:
the old templet =
xxxx
the new templet =
yyyy
zzzz
<script_name> <file_name> xxxx yyyy??zzzz
What has to be instead the ?? in order to split the yyyy and zzzz for tow separate rows ?
10x
Amir
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I get a text file with 70+ columns (seperated by Tab) and about 10000 rows. The 58th Column is all numbers. But sometimes 58th columns has "/xxx=##" after the numeric data. I want to truncate this string using the script. Any Ideas...:confused: (3 Replies)
Discussion started by: gagansharma
3 Replies
2. Shell Programming and Scripting
Looking for a way using sed/awk/perl to replace port numbers in a file with an incrementing number. The original file looks like...
Host cmg-iqdrw3p4
LocalForward *:9043 localhost:9043
Host cmg-iqdro3p3a
LocalForward *:10000 localhost:10000
Host cmg-iqdro3p3b
LocalForward... (2 Replies)
Discussion started by: treadwm
2 Replies
3. Shell Programming and Scripting
Trying to create a script/executable to replace "abc" text string in "myfile.htm" with input from a pop-up field. For example, launch this thing and a prompt is popped up asking the user to input what "abc" should be replaced with, then it inserts what the user inputs in place of abc in the... (3 Replies)
Discussion started by: mike909
3 Replies
4. Shell Programming and Scripting
find . -type f -name "*.sql" -print|xargs perl -i -pe 's/pattern/replaced/g'
this is simple logic to find and replace in multiple files & folders
Hope this helps.
Thanks
Zaheer (0 Replies)
Discussion started by: Zaheer.mic
0 Replies
5. Shell Programming and Scripting
Hi,
I am creating a script to do a find and replace single/multiple lines in a file with any number of lines.
I have written a logic in a script that reads a reference file say "findrep" and populates two variables $FIND and $REPLACE
print $FIND gives
Hi How r $u
Rahul()
Note:... (0 Replies)
Discussion started by: r_sarnayak
0 Replies
6. Shell Programming and Scripting
Hey guys. I know pratically 0 about Linux, so could anyone please give me instructions on how to accomplish this ?
The distro is RedHat 4.1.2 and i need to find and replace a multiple lines string in several php files across subdirectories.
So lets say im at root/dir1/dir2/ , when i execute... (12 Replies)
Discussion started by: spfc_dmt
12 Replies
7. Shell Programming and Scripting
Hi All,
I have a unix shell script file as below.
My task is
a)to replace 248 to 350 and need to create a new file as BW3_350.sh
b)to replace 248 to 380 and need to create a new file as BW3_380.sh
c)to replace 248 to 320 and need to create a new file as BW3_320.sh
there is no... (6 Replies)
Discussion started by: karthi_mrkg
6 Replies
8. UNIX for Dummies Questions & Answers
I am making an eBook.
I am editing the html in BBedit.
I need to replace all <p class="s5"> with just a <p>.
How do I write this for GREP?
Thank you,
Abby (5 Replies)
Discussion started by: cuddlykitty
5 Replies
9. UNIX for Dummies Questions & Answers
Hi
I am looking to rename the contents of this dir, each one with a new timestamp, interval of a second for each so it the existing format is on lhs and what I want is to rename each of these to what is on rhs..hopefully it nake sense
CDR.20060505.150006.gb CDR.20121211.191500.gb... (3 Replies)
Discussion started by: rob171171
3 Replies
10. UNIX for Dummies Questions & Answers
I have text with upper and lower case words. I want to find something and replace it with something new. But it should match the case - Meaning - it should replace old upper cased word with NEW upper case word and lower with lower.
example:
this text is very simple TEXT.
now I want to replace... (5 Replies)
Discussion started by: grep_me
5 Replies
LEARN ABOUT SUSE
gtk2::accelmap
Gtk2::AccelMap(3) User Contributed Perl Documentation Gtk2::AccelMap(3)
NAME
Gtk2::AccelMap
HIERARCHY
Glib::Object
+----Gtk2::AccelMap
METHODS
Gtk2::AccelMap->add_entry ($accel_path, $accel_key, $accel_mods)
o $accel_path (string)
o $accel_key (integer)
o $accel_mods (Gtk2::Gdk::ModifierType)
Gtk2::AccelMap->add_filter ($filter_pattern)
o $filter_pattern (string)
boolean = Gtk2::AccelMap->change_entry ($accel_path, $accel_key, $accel_mods, $replace)
o $accel_path (string)
o $accel_key (integer)
o $accel_mods (Gtk2::Gdk::ModifierType)
o $replace (boolean)
Gtk2::AccelMap->foreach ($data, $foreach_func)
o $data (scalar)
o $foreach_func (scalar)
Gtk2::AccelMap->foreach_unfiltered ($data, $foreach_func)
o $data (scalar)
o $foreach_func (scalar)
accelmap = Gtk2::AccelMap->get
Since: gtk+ 2.4
Gtk2::AccelMap->load ($file_name)
o $file_name (string)
Gtk2::AccelMap->load_fd ($fd)
o $fd (integer)
Gtk2::AccelMap->lock_path ($accel_path)
o $accel_path (string)
Since: gtk+ 2.4
(accel_key, accel_mods, accel_flags) = Gtk2::AccelMap->lookup_entry ($accel_path)
o $accel_path (string)
Returns empty if no accelerator is found for the given path, accel_key (integer), accel_mods (Gtk2::Gdk::ModifierType), and accel_flags
(integer) otherwise.
Gtk2::AccelMap->save ($file_name)
o $file_name (string)
Gtk2::AccelMap->save_fd ($fd)
o $fd (integer)
Gtk2::AccelMap->unlock_path ($accel_path)
o $accel_path (string)
Since: gtk+ 2.4
FOREACH CALLBACK
The foreach callbacks ignore any returned values and the following parameters are passed to the callback any modifications are ignored.
accel_path (string)
accel_key (integer)
GdkModifierType accel_mods (Gtk2::Gdk::ModifierType)
changed (boolean)
user_date (scalar)
SIGNALS
changed (Gtk2::AccelMap, string, Glib::UInt, Gtk2::Gdk::ModifierType)
ENUMS AND FLAGS
flags Gtk2::Gdk::ModifierType
o 'shift-mask' / 'GDK_SHIFT_MASK'
o 'lock-mask' / 'GDK_LOCK_MASK'
o 'control-mask' / 'GDK_CONTROL_MASK'
o 'mod1-mask' / 'GDK_MOD1_MASK'
o 'mod2-mask' / 'GDK_MOD2_MASK'
o 'mod3-mask' / 'GDK_MOD3_MASK'
o 'mod4-mask' / 'GDK_MOD4_MASK'
o 'mod5-mask' / 'GDK_MOD5_MASK'
o 'button1-mask' / 'GDK_BUTTON1_MASK'
o 'button2-mask' / 'GDK_BUTTON2_MASK'
o 'button3-mask' / 'GDK_BUTTON3_MASK'
o 'button4-mask' / 'GDK_BUTTON4_MASK'
o 'button5-mask' / 'GDK_BUTTON5_MASK'
o 'super-mask' / 'GDK_SUPER_MASK'
o 'hyper-mask' / 'GDK_HYPER_MASK'
o 'meta-mask' / 'GDK_META_MASK'
o 'release-mask' / 'GDK_RELEASE_MASK'
o 'modifier-mask' / 'GDK_MODIFIER_MASK'
SEE ALSO
Gtk2, Glib::Object
COPYRIGHT
Copyright (C) 2003-2008 by the gtk2-perl team.
This software is licensed under the LGPL. See Gtk2 for a full notice.
perl v5.12.1 2010-07-05 Gtk2::AccelMap(3)