Sponsored Content
Full Discussion: replacing charater
Top Forums Shell Programming and Scripting replacing charater Post 22082 by LivinFree on Tuesday 28th of May 2002 03:18:22 AM
Old 05-28-2002
Your method is probably safer - copy the file first, then remove later if everything worked correctly...

Either way works!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

running an Acii charater in a script.

Hi, I need to pass a space bar or an enter key in a script for it to return control to my script. How do I do this. For example the spacebar ascii value is 127, how do I tell the script to run this command. (4 Replies)
Discussion started by: quispiam
4 Replies

2. UNIX for Dummies Questions & Answers

Inserting a delimiter after certain charater position

Hi, I have a string : - ICFFHASMTAAMPFINCL22082006000002548789632 and i want to add delimiter after certain charater position through a script, eg. ICFFH,ASMTAAMPF,INCL,22082006,000002548789632. I have tried and am able to achieve it through cut-paste. But i don't want to use cut paste as it... (6 Replies)
Discussion started by: divz
6 Replies

3. Shell Programming and Scripting

help in replacing ??

hi all i have input file like this abc.txt filename.out: <TAB>ABC<TAB>9 <TAB>AKC<TAB>1 filename1.out: <TAB>XYZ<TAB>1 <TAB>XYN<TAB>4 and i am trying to replace \n\t with \t so that output will be like this: filename.out:<TAB>ABC<TAB>9<TAB>AKC<TAB>1... (5 Replies)
Discussion started by: zedex
5 Replies

4. Shell Programming and Scripting

Charater comparison

I have two files. Each file has one line with 2500 charaters in it and both lines should be the same, but thay are not. I need to compare the two lines and find where the differences are. So what I need to do is compare each character one at a time to find out whats different. (4 Replies)
Discussion started by: Tornado
4 Replies

5. Shell Programming and Scripting

replacing using sed

its again sed question. i have line - sed "s/$old/$new/g" "$f" > $TFILE && mv $TFILE "$f" working well if old="myoldfile" new="mynewfile" but if i want old="/home/shailesh/1test/" new="/home/shailesh/workspace/" it gives error like sed: -e expression #1, char 9: unknown option to... (2 Replies)
Discussion started by: shailesh_arya
2 Replies

6. Shell Programming and Scripting

Replacing of word

Hi all, I wanted to replace one word with another word pl help me to solve the same. example:- I wanted to replace RXOTX with RXOTRX in a perticuler file with hole. Regards, Ramesh (2 Replies)
Discussion started by: Ramesh Vellanki
2 Replies

7. Shell Programming and Scripting

Replacing Characters

Hi All, I have a file which is delimeted with the character '. i need to replace this character with the same character and also a new line. Can anyone please help me with the tr command for this. Many thanks Karan (11 Replies)
Discussion started by: karansachdeva
11 Replies

8. Shell Programming and Scripting

replacing / to -

Hi, i am running a shell script where i have assigned a variable to the value passed. so my variable is var1="investment/portfolio/run.job" now i want to assign another variable var2 as "investment-portfolio-run.out" how can i do it using awk or something else.... thanks (2 Replies)
Discussion started by: rudoraj
2 Replies

9. Shell Programming and Scripting

Replacing \n,\n with ,

Hi everyone, I've read lots of posts about tr and sed and such, I haven't been able to get out of this one. I have a file, like this: 1 , Jelle 2 , SandraThe only thing it needs to do is delete the enter between the number and the name. So, it needs to replace \n,\n with , ... (7 Replies)
Discussion started by: skerit
7 Replies

10. Shell Programming and Scripting

Replacing tags

Hi , I have a file ...it's like a xml file. File 1: <tag1> Value11</tag1><tag2>value12</tag2> <tag1>Value21</tag1> ...... Continues Now what I want as output is Value11|value12 Value21|| ......Continues This is just learning purpose. I tried reading each line, then parsing... (14 Replies)
Discussion started by: Anupam_Halder
14 Replies
dpkg-maintscript-helper(1)					    dpkg suite						dpkg-maintscript-helper(1)

NAME
dpkg-maintscript-helper - works around known dpkg limitations in maintainer scripts SYNOPSIS
dpkg-maintscript-helper command [parameter...] -- maint-script-parameter... COMMANDS AND PARAMETERS
rm_conffile conffile [prior-version [package]] mv_conffile old-conffile new-conffile [prior-version [package]] DESCRIPTION
This program is designed to be run within maintainer scripts to achieve some tasks that dpkg can't (yet) handle natively either because of design decisions or due to current limitations. Many of those tasks require coordinated actions from several maintainer scripts (preinst, postinst, prerm, postrm). To avoid mistakes the same call simply needs to be put in all scripts and the program will automatically adapt its behaviour based on the environment variable DPKG_MAINTSCRIPT_NAME and on the maintainer scripts arguments that you have to forward after a double dash. CONFFILE RELATED TASKS
When upgrading a package, dpkg will not automatically remove a conffile (a configuration file for which dpkg should preserve user changes) if it is not present in the newer version. There are two principal reasons for this; the first is that the conffile could've been dropped by accident and the next version could restore it, users wouldn't want their changes thrown away. The second is to allow packages to tran- sition files from a dpkg-maintained conffile to a file maintained by the package's maintainer scripts, usually with a tool like debconf or ucf. This means that if a package is intended to rename or remove a conffile, it must explicitly do so and dpkg-maintscript-helper can be used to implement graceful deletion and moving of conffiles within maintainer scripts. REMOVING A CONFFILE If a conffile is completely removed, it should be removed from disk, unless the user has modified it. If there are local modifications, they should be preserved. If the package upgrades aborts, the newly obsolete conffile should not disappear. All of this is implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts: dpkg-maintscript-helper rm_conffile conffile prior-version package -- "$@" conffile is the filename of the conffile to remove. prior-version defines the latest version of the package whose upgrade should trigger the removal. It is important to calculate prior-ver- sion correctly so that conffiles are correctly removed even if the user rebuilt the package with a local version. For example, for a conf- file removed in version 2.0-1 of a package, prior-version should be set to 2.0-1~. This will cause the conffile to be removed even if the user rebuilt the previous version 1.0-1 as 1.0-1local1. If the conffile has not been shipped for several versions, and you are now modifying the maintainer scripts to clean up the obsolete file, prior-version should be based on the version of the package that you are now preparing, not the first version of the package that lacked the conffile. package is the package name. If empty or omitted, the DPKG_MAINTSCRIPT_PACKAGE environment variable (as set by dpkg) will be used. All the parameters of the maintainer scripts have to be forwarded to the program after "--". Current implementation: in the preinst, it checks if the conffile was modified and renames it either to conffile.dpkg-remove (if not modi- fied) or to conffile.dpkg-backup (if modified). In the postinst, the latter file is renamed to conffile.dpkg-bak and kept for reference as it contains user modifications but the former will be removed. If the package upgrade aborts, the postrm reinstalls the original conffile. During purge, the postrm will also delete the .dpkg-bak file kept up to now. RENAMING A CONFFILE If a conffile is moved from one location to another, you need to make sure you move across any changes the user has made. This may seem a simple change to the preinst script at first, however that will result in the user being prompted by dpkg to approve the conffile edits even though they are not responsible of them. Graceful renaming can be implemented by putting the following shell snippet in the preinst, postinst and postrm maintainer scripts: dpkg-maintscript-helper mv_conffile old-conffile new-conffile prior-version package -- "$@" old-conffile and new-conffile are the old and new name of the conffile to rename. prior-version defines the latest version of the package whose upgrade should trigger the rename of the conffile (see the notes for rm_conf- file above concerning the correct value). If prior-version is empty or omitted, then the operation is tried on every upgrade (note: it's safer to give the version and have the operation tried only once). package is the package name. If empty or omitted, the DPKG_MAINTSCRIPT_PACKAGE environment variable (as set by dpkg) will be used. All the parameters of the maintainer scripts have to be forwarded to the program after "--". Current implementation: the preinst checks if the conffile has been modified, if yes it's left on place otherwise it's renamed to old-conf- file.dpkg-remove. On configuration, the postinst removes old-conffile.dpkg-remove and renames old-conffile to new-conffile if old-conffile is still available. On abort-upgrade/abort-install, the postrm renames old-conffile.dpkg-remove back to old-conffile if required. INTEGRATION IN PACKAGES
Given that dpkg-maintscript-helper is used in the preinst, using it unconditionally requires a pre-dependency to ensure that the required version of dpkg has been unpacked before. The required version depends on the command used, for rm_conffile and mv_conffile it is 1.15.7.2: Pre-Depends: dpkg (>= 1.15.7.2) But in many cases the operation done by the program is not critical for the package, and instead of using a pre-dependency we can call the program only if we know that the required command is supported by the currently installed dpkg: if dpkg-maintscript-helper supports command; then dpkg-maintscript-helper command ... fi Debian Project 2012-05-04 dpkg-maintscript-helper(1)
All times are GMT -4. The time now is 01:53 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy