Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Switch and replace columns in a file Post 302551007 by rs1969 on Monday 29th of August 2011 05:05:50 AM
Old 08-29-2011
Quote:
Originally Posted by Shell_Life
To replace space columns from 24 to 31:
Code:
mTo='00010101'
sed "s/\(.\{23\}\)[ ]\{8\}\(.*\)/\1${mTo}\2/" Inp_File

You can run it before or after your awk.
Thanks a lot Smilie

How to check if column has a certain value? For example, I want to check if columns from 50 to 60 has '@@' then replace with spaces. Can I perform multiple find and replace with one call to sed or they need to be done separately?
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How can i replace certain columns in the file

Can i use sed command to replace certain column in the file let say i hav D1254215221542 MANA3DS2OOR454 C1254815221121 MDGA4GH4OOR454 A1254215221522 AFFA4DF4OODS54 S3454815221121 TDTA4GH465R454 I wanted to change only at postition 21 and 22 which is DS,GH,DF and GH i want find that if... (6 Replies)
Discussion started by: mani_um
6 Replies

2. Shell Programming and Scripting

Replace specific columns

hi All, Thi sis very urgent. I have large files with pipe delimited. For example: 1.txt 1001024|120|9|-0.0|#| 1001025|120|9|#| 1001026|120|9|#| 1001032|120|2|-0.0|#| 1002026|110|9|#| 1002027|110|9|-0.0|#| 1002028|120|1|1.0|#| I need to replace the 4th filed if it is # by |-| my... (2 Replies)
Discussion started by: jisha
2 Replies

3. UNIX for Dummies Questions & Answers

Replace columns from File1 with columns from File2

Hi all, I would like to replace some columns from file1 with columns from file2. Currently, I'm able to do it with the following command: awk 'NR==FNR{a=$1;b=$2;c=$3;next;} {$2=a;$4=b;$5=c;print}' file2 file1 > temp mv -f temp file1 First, i make the changes and save it as a temp... (1 Reply)
Discussion started by: seijihiko
1 Replies

4. Shell Programming and Scripting

Replace specific columns in one file with columns in another file

HELLO! This is my first post here! By the way, I think it is great that people do this. My question: I have two files, one is a .dilm and one is a .txt. It is my understanding that the .dilm file can be treated as a .txt file. I wrote another program where I was able to manipulate it as if it... (3 Replies)
Discussion started by: mehdib
3 Replies

5. Shell Programming and Scripting

Replace columns of one file into another

Hi, I have two files that are different in size (column #'s differ). Each file has the exact same 3 starting columns. File 1 has 240 columns while File 2 has 45 columns. So if the first 3 columns are the same, I want to replace columns 83 to 163 from File 1 with columns 18 to 33 from File... (7 Replies)
Discussion started by: kylle345
7 Replies

6. Shell Programming and Scripting

Error while executing switch case for find and replace specific file. Help Me...

case "$inputs" in sapte) find /pools/home_unix/sapte/work/models/model -name "*.xml" exec rm -i {} \;; ckm1) find /pools/home_unix/ckm1/work/models/model -name "*.xml" exec rm -i {} \;; I am getting error like as below. ./menu1.sh: line 144: syntax error near unexpected token `)'... (4 Replies)
Discussion started by: lathigara
4 Replies

7. Shell Programming and Scripting

Replace text in column1 of a file matching columns of another file

Hi all, I have 2 files: species-names.txt Abaca-bunchy-top-virus ((((Abaca-bunchy-top-virus((Babuvirus((Unassigned((Nanoviridae((Unassigned)))) Abutilon-mosaic-virus ((((Abutilon-mosaic-virus((Begomovirus((Unassigned((Geminiviridae((Unassigned))))... (2 Replies)
Discussion started by: thienxho
2 Replies

8. Shell Programming and Scripting

Match on columns and replace other columns

Hi Friends, I have the following input file cat input chr1 100 200 0.1 0.2 na 1 na nd chr1 105 200 0.1 0.2 1 1 na 98 chr1 110 290 nf 1 na nd na 1 chr2 130 150 12 3 na 1 na 1 chr3 450 600 nf nf na 10 na nd chr4 300 330 1 1 10 11 23 34 My requirement is 1. If $6 is na make $7 nd and... (2 Replies)
Discussion started by: jacobs.smith
2 Replies

9. Shell Programming and Scripting

Replace values in columns

I have the following input format: AA00000712000 -0.17 0.90 -1.04 -0.37 -1.45 -1.13 -0.22 -0.34 -0.55 2.37 0.67 -0.48 -0.48 AA00000712001 0.15 0.03 0.47 0.62 2.04 1.14 0.29 -0.81 0.85 0.53 1.00 -0.10 -0.48 BB00000712000 1.32 -0.47 0.44 0.00 0.98 ... (4 Replies)
Discussion started by: ncwxpanther
4 Replies

10. Shell Programming and Scripting

Replace text in columns

I have two files in below formats: cat file1 abc|abcd|10|1020 10|xyz|1010|1020 abc|abcd|10|1020 10|xyz|1010|1020 cat file2 abc|abcd|10|1020 11|xyz|1010|1020 abc|abcd|12|1020 10|xyz|1011|1020 abc|abcd|11|1020 10|xyz|1010|1020 abc|abcd|10|1020 10|xyz|1010|1020 I am generating a... (3 Replies)
Discussion started by: ctrld
3 Replies
REPL(1)                                                              [nmh-1.5]                                                             REPL(1)

NAME
repl - reply to a message SYNOPSIS
repl [+folder] [msgs] [-annotate | -noannotate] [-group | -nogroup] [-cc all/to/cc/me] [-nocc all/to/cc/me] [-query | -noquery] [-form formfile] [-format | -noformat] [-filter filterfile] [-inplace | -noinplace] [-mime | -nomime] [-fcc +folder] [-width columns] [-draftfolder +folder] [-draftmessage msg] [-nodraftfolder] [-editor editor] [-noedit] [-whatnowproc program] [-nowhatnowproc] [-atfile] [-noatfile] [-fmtproc program] [-nofmtproc] [-build] [-file msgfile] [-version] [-help] DESCRIPTION
Repl may be used to produce a reply to an existing message. In its simplest form (with no arguments), repl will set up a message-form skeleton in reply to the current message in the current folder, and invoke the whatnow shell. In order to construct the message draft of the reply, repl uses a reply template to guide its actions. A reply template is simply a mhl format file (see mh-format(5) for details). If the switch -nogroup is given (it is on by default), then repl will use the standard forms file "replcomps". This will construct a draft message that is intended to be sent only to the author of the message to which you are replying. If a file named "replcomps" exists in the user's nmh directory, it will be used instead of this default forms file. The default reply template "replcomps" will direct repl to construct the reply message draft as follows: To: <Mail-Reply-To> or <Reply-To> or <From> cc: <To> and <cc> and <personal address> Fcc: {fcc switch} or +outbox Subject: Re: <Subject> In-Reply-To: <Message-Id> References: <Message-Id> Comments: In-Reply-To <From> or <apparently from> or <Sender> message dated <date> -------- where field names enclosed in angle brackets (< >) indicate the contents of the named field from the message to which the reply is being made. By default, the "cc:" field is empty. You may selectively add addresses to this default with the -cc type switch. This switch takes an argument ( all/to/cc/me) which specifies who gets added to the default "cc:" list of the reply. You may give this switch multiple times (with different arguments) if you wish to add multiple types of addresses. If the switch -group is given, then repl will use the the standard forms file "replgroupcomps". This will construct a draft message that is intended as a group or followup reply. If a file named "replgroupcomps" exists in the user's nmh directory, it will be used instead of this default forms file. The default group reply template "replgroupcomps" will direct repl to construct the reply message draft as follows: To: <Mail-Followup-To> Subject: Re: <Subject> In-Reply-To: Message from <From> of <Date>. <Message-Id> -------- or if the field <Mail-Followup-To> is not available: To: <Mail-Reply-To> or <Reply-To> or <From> cc: <To> and <cc> and <personal address> Subject: Re: <Subject> In-Reply-To: Message from <From> of <Date>. <Message-Id> -------- By default, the "cc:" contains all the addresses shown. You may selectively remove addresses from this default with the -nocc type switch. This switch takes an argument ( all/to/cc/me) which specifies who gets removed from the default "cc:" list of the reply. You may give this switch multiple times (with different arguments) if you wish to remove multiple types of addresses. In any case, you may specify an alternate forms file with the switch -form formfile. The -query switch modifies the action of -nocc type switch by interactively asking you if each address that normally would be placed in the "To:" and "cc:" list should actually be sent a copy. This is useful for special-purpose replies. Note that the position of the -cc and -nocc switches, like all other switches which take a positive and negative form, is important. Lines beginning with the fields "To:", "cc:", and "Bcc:" will be standardized and have duplicate addresses removed. In addition, the -width columns switch will guide repl's formatting of these fields. If the draft already exists, repl will ask you as to the disposition of the draft. A reply of quit will abort repl, leaving the draft intact; replace will replace the existing draft with a blank skeleton; and list will display the draft. See comp(1) for a description of the -editor and -noedit switches. Note that while in the editor, the message being replied to is avail- able through a link named "@" (assuming the default whatnowproc). In addition, the actual pathname of the message is stored in the envi- ronment variable $editalt, and the pathname of the folder containing the message is stored in the environment variable $mhfolder. The cre- ation of the "@" file and associated environment variables can be controlled via the -atfile and -noatfile options. Although repl uses a forms file to direct it how to construct the beginning of the draft, it uses a message filter file to direct it as to how the message to which you are replying should be filtered (re-formatted) in the body of the draft. The filter file for repl should be a standard form file for mhl, as repl will invoke mhl to format the message to which you are replying. The switches -noformat, -format, and -filter filterfile specify which message filter file to use. If the switch -noformat is given (it is the default), then the message to which you are replying is not included in the body of the draft. If the switch -format is given, then a default message filter file is used. This default message filter should be adequate for most users. This default filter "mhl.reply" is: ; mhl.reply ; ; default message filter for `repl' (repl -format) ; from:nocomponent,formatfield="%(decode(friendly{text})) writes:" body:component="> ",overflowtext="> ",overflowoffset=0 which outputs each line of the body of the message prefaced with the ">" character and a space. If a file named "mhl.reply" exists in the user's nmh directory, it will be used instead of this form. You may specify an alternate message filter file with the switch -filter filterfile. Other reply filters are commonly used, such as: : body:nocomponent,compwidth=9,offset=9 which says to output a blank line and then the body of the message being replied-to, indented by one tab-stop. Another popular format is: message-id:nocomponent,nonewline, formatfield="In message %{text}, " from:nocomponent,formatfield="%(decode(friendly{text})) writes:" body:component=">",overflowtext=">",overflowoffset=0 This message filter file cites the Message-ID and author of the message being replied-to, and then outputs each line of the body prefaced with the ">" character. You can also use an external format program to format the message body. The format program is specified by the formatproc profile entry, and is enabled by the "format" flag. A message filter using an external format program would look like this: body:component=">",nowrap,format See the mhl(1) documentation for more information. The format program can be changed by the -fmtproc program and -nofmtproc switches. To use the MIME rules for encapsulation, specify the -mime switch. This directs repl to generate an mhbuild composition file. Note that nmh will not invoke mhbuild automatically, unless you add this line to your .mh_profile file: automimeproc: 1 Otherwise, you must specifically give the command What now? mime prior to sending the draft. If the -annotate switch is given, the message being replied-to will be annotated with the lines Replied: date Replied: addrs where the address list contains one line for each addressee. The annotation will be done only if the message is sent directly from repl. If the message is not sent immediately from repl, "comp -use" may be used to re-edit and send the constructed message, but the annotations won't take place. Normally annotations are done inplace in order to preserve any links to the message. You may use the -noinplace switch to change this. Although the default template specifies that a copy of the reply will be put in the folder 'outbox', if the -fcc +folder switch is given it will override the default value. More than one folder, each preceded by -fcc can be named. In addition to the standard mh-format(5) escapes, repl also recognizes the following additional component escape: Escape Returns Description fcc string Any folders specified with `-fcc folder' To avoid reiteration, repl strips any leading `Re: ' strings from the subject component. The -draftfolder +folder and -draftmessage msg switches invoke the nmh draft folder facility. This is an advanced (and highly useful) fea- ture. Consult the mh-draft(5) man page for more information. Upon exiting from the editor, repl will invoke the whatnow program. See whatnow(1) for a discussion of available options. The invocation of this program can be inhibited by using the -nowhatnowproc switch. (In truth of fact, it is the whatnow program which starts the initial edit. Hence, -nowhatnowproc will prevent any edit from occurring.) The -build switch is intended to be used by the Emacs mh-e interface to nmh. It implies -nowhatnowproc. It causes a file <mh-dir>/reply to be created, containing the draft message that would normally be presented to the user for editing. No mail is actually sent. The -file msgfile switch specifies the message to be replied to as an exact filename rather than as an nmh folder and message number. It is intended to be used by the msh interface to nmh. The same caveats apply to this option as to the -build switch. FILES
/etc/nmh/replcomps The standard reply template or <mh-dir>/replcomps Rather than the standard template /etc/nmh/replgroupcomps The standard `reply -group' template or <mh-dir>/replgroupcomps Rather than the standard template /etc/nmh/mhl.reply The standard message filter or <mh-dir>/mhl.reply Rather than the standard filter $HOME/.mh_profile The user profile <mh-dir>/draft The draft file PROFILE COMPONENTS
Path: To determine the user's nmh directory Alternate-Mailboxes: To determine the user's mailboxes Current-Folder: To find the default current folder Draft-Folder: To find the default draft-folder Editor: To override the default editor Msg-Protect: To set mode when creating a new message (draft) fileproc: Program to refile the message mhlproc: Program to filter message being replied-to whatnowproc: Program to ask the "What now?" questions SEE ALSO
mhbuild(1), comp(1), forw(1), send(1), whatnow(1), mh-format(5) DEFAULTS
`+folder' defaults to the current folder `msg' defaults to cur `-nogroup' `-nocc all' with `-nogroup', `-cc all' with `-group' `-noannotate' `-nodraftfolder' `-noformat' `-inplace' `-nomime' `-noquery' `-atfile' `-width 72' CONTEXT
If a folder is given, it will become the current folder. The message replied-to will become the current message. BUGS
If any addresses occur in the reply template, addresses in the template that do not contain hosts are defaulted incorrectly. Instead of using the localhost for the default, repl uses the sender's host. Moral of the story: if you're going to include addresses in a reply tem- plate, include the host portion of the address. The -width columns switch is only used to do address-folding; other headers are not line-wrapped. If whatnowproc is whatnow, then repl uses a built-in whatnow, it does not actually run the whatnow program. Hence, if you define your own whatnowproc, don't call it whatnow since repl won't run it. If your current working directory is not writable, the link named "@" is not available. MH.6.8 11 June 2012 REPL(1)
All times are GMT -4. The time now is 11:28 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy