Sponsored Content
Top Forums Shell Programming and Scripting sed command - substitue first instance Post 302070456 by d_swapneel14 on Wednesday 5th of April 2006 04:25:11 AM
Old 04-05-2006
not a home work

hi,
see i m able to use sed command. i dont have any sytex errores. might be while typing here i missed out something.

see i m using sed command but i want to replace only first /or nth instance in file. i dont want replace all instances .

i repeat only first instance.

And guys thisis not home work. plz reply with solutions.

thanks
Swapneel
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed replace 2nd instance

Hello, I want to replace 2nd instance of "foo" in a file use sed. Any suggestions? (2 Replies)
Discussion started by: katrvu
2 Replies

2. Shell Programming and Scripting

Sed on first instance only

Hi, I've been trying to figure this one out and found a post about this on the forum here but the solution didn't seem to work for me. Basically what I have is a file that looks something like: stuff morestuff 0 otherthing 0 etc I want to substitute for the 0 but what I want to... (9 Replies)
Discussion started by: eltinator
9 Replies

3. Shell Programming and Scripting

sed appending needed only after first instance

Hi, Here is my piece of code used with sed in shell script: sed -i '/<falsemodule-option>/ a\<LdapLogin>' myxmlfile The problem that i am facing with the above is that in 'myxml' file i have mulitple instances of <falsemodule-option> so when i execute the above sed command, it is appending... (10 Replies)
Discussion started by: sunrexstar
10 Replies

4. Shell Programming and Scripting

sed: how to limit pattern search to first instance only

I need to reduce a file's size below 50MB by deleting chucks of text. The following sed does this. sed '/^begpattern/,/endpattern/d' myfile However, it's possible that the file size can get below 50MB by just deleting the first instance of the pattern. How do I code that into sed? Or can awk... (8 Replies)
Discussion started by: mariod1049
8 Replies

5. Homework & Coursework Questions

Bash Scripting - sed (substitue)

1. The problem statement, all variables and given/known data: I have been asked to create a bash script to delete comments from another file but in the file they have an echo command with this inside of it /* this is an echo */\ so obviously they want to keep this one in the file. I have found... (5 Replies)
Discussion started by: syco__
5 Replies

6. Shell Programming and Scripting

Using sed can you specify the last instance of a character on a line?

I was told a way to do this with awk earlier today but is there a way with sed to specify the last instance of a character on a line? You will know what character you're looking for but there could be none or one hundred instances of it on a line say and you ONLY want to specify the last one for... (3 Replies)
Discussion started by: Bashingaway
3 Replies

7. Shell Programming and Scripting

sed command to print first instance of pattern in range

The following text is in testFile.txt: one 5 two 10 three 15 four 20 five 25 six 10 seven 35 eight 10 nine 45 ten 50 I'd like to use sed to print the first occurance of search pattern /10/ in a given range. This command is to be run against large log files, so to optimize efficiency,... (9 Replies)
Discussion started by: uschaafm
9 Replies

8. Shell Programming and Scripting

sed for first instance of a pattern

Hi Everyone, I have the below information from a log file: LOAD SUMMARY ============ WRT_8036 Target: TGT_1_TAB (Instance Name: ) WRT_8039 Inserted rows - Requested: 3929 Applied: 0 Rejected: 3929 Affected: 0 Mutated from update: 3929 WRT_8041 Updated rows ... (7 Replies)
Discussion started by: galaxy_rocky
7 Replies

9. Shell Programming and Scripting

sed to grab first instance of a range

Hi all, I'm new to the forum and also relatively new to sed and other such wonderfully epic tools. I'm attempting to grab a section of text between two words, but it seems to match all instances of the range instead of stopping at just the first. This occurs when I use: sed -n... (7 Replies)
Discussion started by: Lazarix
7 Replies

10. Shell Programming and Scripting

sed substitue whole file + 1 substitue with variables on one sed line?.

I'm trying to remove '--X' from the whole file and using variables replace $oldvar with $newvar. I have tried with double quotes but it doesn't seem to work. $newvar is set to /usr/bin/bash. Would appreciate some guidance. newvar=$(which bash) oldvar=/bin/bash sed... (1 Reply)
Discussion started by: itman73
1 Replies
POSTFIX-WRAPPER(5)						File Formats Manual						POSTFIX-WRAPPER(5)

NAME
postfix-wrapper - Postfix multi-instance API DESCRIPTION
Support for managing multiple Postfix instances is available as of version 2.6. Instances share executable files and documentation, but have their own directories for configuration, queue and data files. This document describes how the familiar "postfix start" etc. user interface can be used to manage one or multiple Postfix instances, and gives details of an API to coordinate activities between the postfix(1) command and a multi-instance manager program. With multi-instance support, the default Postfix instance is always required. This instance is identified by the config_directory parame- ter's default value. GENERAL OPERATION
Multi-instance support is backwards compatible: when you run only one Postfix instance, commands such as "postfix start" will not change behavior at all. Even with multiple Postfix instances, you can keep using the same postfix commands in boot scripts, upgrade procedures, and other places. The commands do more work, but humans are not forced to learn new tricks. For example, to start all Postfix instances, use: # postfix start Other postfix(1) commands also work as expected. For example, to find out what Postfix instances exist in a multi-instance configuration, use: # postfix status This enumerates the status of all Postfix instances within a multi-instance configuration. MANAGING AN INDIVIDUAL POSTFIX INSTANCE
To manage a specific Postfix instance, specify its configuration directory on the postfix(1) command line: # postfix -c /path/to/config_directory command Alternatively, the postfix(1) command accepts the instance's configuration directory via the MAIL_CONFIG environment variable (the -c com- mand-line option has higher precedence). Otherwise, the postfix(1) command will operate on all Postfix instances. ENABLING
POSTFIX(1) MULTI-INSTANCE MODE By default, the postfix(1) command operates in single-instance mode. In this mode the command invokes the postfix-script file directly (currently installed in the daemon directory). This file contains the commands that start or stop one Postfix instance, that upgrade the configuration of one Postfix instance, and so on. When the postfix(1) command operates in multi-instance mode as discussed below, the command needs to execute start, stop, etc. commands for each Postfix instance. This multiplication of commands is handled by a multi-instance manager program. Turning on postfix(1) multi-instance mode goes as follows: in the default Postfix instance's main.cf file, 1) specify the pathname of a multi-instance manager program with the multi_instance_wrapper parameter; 2) populate the multi_instance_directories parameter with the configuration directory pathnames of additional Postfix instances. For example: /etc/postfix/main.cf: multi_instance_wrapper = $daemon_directory/postfix-wrapper multi_instance_directories = /etc/postfix-test The $daemon_directory/postfix-wrapper file implements a simple manager and contains instructions for creating Postfix instances by hand. The postmulti(1) command provides a more extensive implementation including support for life-cycle management. The multi_instance_directories and other main.cf parameters are listed below in the CONFIGURATION PARAMETERS section. In multi-instance mode, the postfix(1) command invokes the $multi_instance_wrapper command instead of the postfix-script file. This multi- instance manager in turn executes the postfix(1) command in single-instance mode for each Postfix instance. To illustrate the main ideas behind multi-instance operation, below is an example of a simple but useful multi-instance manager implementa- tion: #!/bin/sh : ${command_directory?"do not invoke this command directly"} POSTCONF=$command_directory/postconf POSTFIX=$command_directory/postfix instance_dirs=`$POSTCONF -h multi_instance_directories | sed 's/,/ /'` || exit 1 err=0 for dir in $config_directory $instance_dirs do case "$1" in stop|abort|flush|reload|drain) test "`$POSTCONF -c $dir -h multi_instance_enable`" = yes || continue;; start) test "`$POSTCONF -c $dir -h multi_instance_enable`" = yes || { $POSTFIX -c $dir check || err=$? continue };; esac $POSTFIX -c $dir "$@" || err=$? done exit $err PER-INSTANCE MULTI-INSTANCE MANAGER CONTROLS Each Postfix instance has its own main.cf file with parameters that control how the multi-instance manager operates on that instance. This section discusses the most important settings. The setting "multi_instance_enable = yes" allows the multi-instance manager to start (stop, etc.) the corresponding Postfix instance. For safety reasons, this setting is not the default. The default setting "multi_instance_enable = no" is useful for manual testing with "postfix -c /path/name start" etc. The multi-instance manager will not start such an instance, and it will skip commands such as "stop" or "flush" that require a running Postfix instance. The multi-instance manager will execute commands such as "check", "set-permissions" or "upgrade-configuration", and it will replace "start" by "check" so that problems will be reported even when the instance is disabled. MAINTAINING SHARED AND NON-SHARED FILES Some files are shared between Postfix instances, such as executables and manpages, and some files are per-instance, such as configuration files, mail queue files, and data files. See the NON-SHARED FILES section below for a list of per-instance files. Before Postfix multi-instance support was implemented, the executables, manpages, etc., have always been maintained as part of the default Postfix instance. With multi-instance support, we simply continue to do this. Specifically, a Postfix instance will not check or update shared files when that instance's config_directory value is listed with the default main.cf file's multi_instance_directories parameter. The consequence of this approach is that the default Postfix instance should be checked and updated before any other instances. MULTI-INSTANCE API SUMMARY Only the multi-instance manager implements support for the multi_instance_enable configuration parameter. The multi-instance manager will start only Postfix instances whose main.cf file has "multi_instance_enable = yes". A setting of "no" allows a Postfix instance to be tested by hand. The postfix(1) command operates on only one Postfix instance when the -c option is specified, or when MAIL_CONFIG is present in the process environment. This is necessary to terminate recursion. Otherwise, when the multi_instance_directories parameter value is non-empty, the postfix(1) command executes the command specified with the multi_instance_wrapper parameter, instead of executing the commands in postfix-script. The multi-instance manager skips commands such as "stop" or "reload" that require a running Postfix instance, when an instance does not have "multi_instance_enable = yes". This avoids false error messages. The multi-instance manager replaces a "start" command by "check" when a Postfix instance's main.cf file does not have "multi_instance_enable = yes". This substitution ensures that problems will be reported even when the instance is disabled. No Postfix command or script will update or check shared files when its config_directory value is listed in the default main.cf's multi_instance_directories parameter value. Therefore, the default instance should be checked and updated before any Postfix instances that depend on it. Set-gid commands such as postdrop(1) and postqueue(1) effectively append the multi_instance_directories parameter value to the legacy alternate_config_directories parameter value. The commands use this information to determine whether a -c option or MAIL_CONFIG environment setting specifies a legitimate value. The legacy alternate_config_directories parameter remains necessary for non-default Postfix instances that are running different versions of Postfix, or that are not managed together with the default Postfix instance. ENVIRONMENT VARIABLES
MAIL_CONFIG When present, this forces the postfix(1) command to operate only on the specified Postfix instance. This environment variable is exported by the postfix(1) -c option, so that postfix(1) commands in descendant processes will work correctly. CONFIGURATION PARAMETERS
The text below provides only a parameter summary. See postconf(5) for more details. multi_instance_directories (empty) An optional list of non-default Postfix configuration directories; these directories belong to additional Postfix instances that share the Postfix executable files and documentation with the default Postfix instance, and that are started, stopped, etc., together with the default Postfix instance. multi_instance_wrapper (empty) The pathname of a multi-instance manager command that the postfix(1) command invokes when the multi_instance_directories parameter value is non-empty. multi_instance_name (empty) The optional instance name of this Postfix instance. multi_instance_group (empty) The optional instance group name of this Postfix instance. multi_instance_enable (no) Allow this Postfix instance to be started, stopped, etc., by a multi-instance manager. NON-SHARED FILES config_directory (see 'postconf -d' output) The default location of the Postfix main.cf and master.cf configuration files. data_directory (see 'postconf -d' output) The directory with Postfix-writable data files (for example: caches, pseudo-random numbers). queue_directory (see 'postconf -d' output) The location of the Postfix top-level queue directory. SEE ALSO
postfix(1) Postfix control program postmulti(1) full-blown multi-instance manager $daemon_directory/postfix-wrapper simple multi-instance manager LICENSE
The Secure Mailer license must be distributed with this software. AUTHOR(S) Wietse Venema IBM T.J. Watson Research P.O. Box 704 Yorktown Heights, NY 10598, USA POSTFIX-WRAPPER(5)
All times are GMT -4. The time now is 07:47 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy