Sponsored Content
Top Forums Shell Programming and Scripting Delete 79th character if it is '_' Post 302771082 by LMHmedchem on Tuesday 19th of February 2013 03:21:52 PM
Old 02-19-2013
Delete 79th character if it is '_'

I have some data that must have been two lines at some point. If the string in one cell is longer than 78 characters, the 79th character is a blank space. This was probably a return that was converted to a space somewhere along the line. This data is processed by some code that replaces blank spaces with underscrore. The result is an underscore at the 79th position that does not belong there.

For example:
N-{[3,4-dihydroxy-5-(hydroxymethyl)oxolan-2-yl]amino}(2-hydroxyphenyl)carboxam_ide

These files have tens of thousands to hunderds of thousands of rows, so this definately calls for a script. Is there a way I can check the 79th character of each string and if it is _, delete it? I can copy the column to a file if that would be easier, otherwise I will have to tell the script which column to process.

Here is a short sample of one of the columns that I need to process:
Code:
IUPACNAME
2-(2-cyclopropyl-2-oxoethylthio)-4,6-dimethylpyridine-3-carbonitrile
N-{[3,4-dihydroxy-5-(hydroxymethyl)oxolan-2-yl]amino}(2-hydroxyphenyl)carboxam_ide
butyl[(5-chloro-1-phenylpyrazol-4-yl)sulfonyl]amine
(1S,8R,9R)-10,14-dioxa-2,3,5,7-tetraazatetracyclo[6.4.1.1<9,12>.0<2,6>
(8S,8aR)-6-amino-2-benzyl-8-[2-(trifluoromethyl)phenyl]-1,2,3,7,8,8a-hexahydro_isoquinoline-5,7,7-tricarbonitrile
3-[N-(4-{[4-(3-carboxypropanoylamino)phenyl]sulfonyl}phenyl)carbamoyl]propanoi_c_acid
1-(phenylcarbonyl)-2-(3-pyridyl)-1,2,3,3a-tetrahydropyridino[2,3-e]indolizine-_3,3-dicarbonitrile
N-[(1E)-2-(3-phenylpyrazol-4-yl)-1-azavinyl]-2-[(3-fluorophenyl)carbonylamino]_acetamide
2-(5-acetyl-3-cyano-6-methyl(2-pyridylthio))-N-benzylacetamide

If the string is <79 characters, it can be skipped.

Thanks for the advice,

LMHmedchem
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Delete first 2 character from string

Hi ! All, I have to delete first 2 characters from string. How its possible? Like string value is "2001". I required output as "01" Plaese help me. Nitin (4 Replies)
Discussion started by: nitinshinde
4 Replies

2. UNIX for Advanced & Expert Users

How to delete a character

Hi, T think this is a question for Perderabo. If you think you know the answer you must be very good ! :) Most of us know how the make the <backspace> key backspace a character. Now how do I make the <delete> key delete a character. !! So when I press the delete key the character after... (3 Replies)
Discussion started by: davidg
3 Replies

3. Shell Programming and Scripting

Use sed to delete a character

I built a 12 million record file and made a mistake, one field is 1 character too long. The record is 40 bytes and ends always in 999. I am trying to delete the 37 character in each record. Is this possible without doing a cut and paste. (1 Reply)
Discussion started by: bthomas
1 Replies

4. Shell Programming and Scripting

delete \n character

Hello. I'm next problem.. I'm a tmp file $ cat tmp word1 word2 word3 word4 and I like have word1 word2 word3 word4 I try with: $ cat tmp |sed 's/\n//' word1 word2 word3 (2 Replies)
Discussion started by: ReneVielma
2 Replies

5. UNIX for Dummies Questions & Answers

Delete between 10th character and 20th character

Hi, I have a .txt and I need to delete the characters betwwen the 10th and 20th... How can I do that... I need to do somethink like these: %s/I don't know how to define a range between 10th and 20th character//g Can you help me... If I want the 10 first characters i do this:... (2 Replies)
Discussion started by: nuno_fbo
2 Replies

6. Shell Programming and Scripting

Delete character from a word

Friends, I'm looking for a command that delete the first tho caractere in a word. Here is an exp : I want to replace "20091001" by "091001" or "replace" by "place" Thx, (13 Replies)
Discussion started by: newpromo
13 Replies

7. Shell Programming and Scripting

sed to delete character 0 only when it's on its own?

Hi all I am trying to get my head around doing the following.... I have an input field that could contain either a number a blank field or a whitespace field. What I want to do is delete a 0 (zero) if it's on its own or leading the number. So:- \t0 delete the zero 0 delete the... (8 Replies)
Discussion started by: Bashingaway
8 Replies

8. Shell Programming and Scripting

delete all symbolic character

Hello is there a way to delete all symbolic characters using the tr command or delete everything apart from letters for example input="u;'#n] i would like echo $input to be "unix" or a way to only accept letters PLEASE HELP:wall: (4 Replies)
Discussion started by: omaral
4 Replies

9. Shell Programming and Scripting

Sed: delete on each line before a character and after a character

Hi there, A total sed noob here. Is there a way using sed to delete everything before a character AND after another character on each line in a file? The deletion should also delete the indicating characters(here: an opening and a closing parenthesis). The original file would look like... (3 Replies)
Discussion started by: bnbsd
3 Replies

10. Shell Programming and Scripting

Count specific character of a file in each line and delete this character in a specific position

I will appreciate if you help me here in this script in Solaris Enviroment. Scenario: i have 2 files : 1) /tmp/TRANSACTIONS_DAILY_20180730.txt: 201807300000000004 201807300000000005 201807300000000006 201807300000000007 201807300000000008 2)... (10 Replies)
Discussion started by: teokon90
10 Replies
expand(1)						      General Commands Manual							 expand(1)

NAME
expand, unexpand - expand tabs to spaces, and vice versa SYNOPSIS
tablist] [file ...] tablist] [file ...] Obsolescent: tabstop] tabn] [file ...] DESCRIPTION
processes the named files or the standard input and writes to the standard output with tabs changed into spaces. Backspace characters are preserved in the output, and the column count is decreased by one column for tab calculations. For proper tab calculation, if a multi-col- umn character is to be "backspace'd", it should be followed by multiple backspace characters which equal to it's column width. If a tab character is found after the last tab position, it is replaced by a single space. is useful for preprocessing character files that contain tabs (before sorting, looking at specific columns, etc). recognizes the following command-line options and arguments: tablist specifies where to set the tab positions instead of the default tablist can take two forms. If it is a single num- ber, tabs are set tablist spaces apart. tablist can also be a blank- or comma-separated list of increasing positions where tabs are to be set. This option is obsolescent and is equivalent to using This option is obsolescent and is equivalent to using processes the named files or the standard input and writes to the standard output with spaces changed into tabs where possible. By default, only leading spaces and tabs are converted to maximal strings of tabs. The default tab position is every 8 characters. Backspace characters are preserved into the output, and the column count is decreased by one column for tab calculations. For proper tab calcula- tion, if a multi-column character is to be "backspace'd", it should be followed by multiple backspace characters which equal to it's column width. recognizes the following command-line options and arguments: Tabs are inserted whenever they would compress the resultant file by replacing two or more spaces before a tab position. tablist specifies the tab positions. tablist can take two forms. If it is a single number, tabs are set every tablist spa- ces apart. If tablist is a blank- or comma-separated list of increasing positions, tabs are set at those locations. The option implies the option. If the option is not specified, the default is equivalent to specifying except that is not implied for this case. EXTERNAL INFLUENCES
Environment Variables determines the interpretation of text as single and/or multi-byte characters. determines the language in which messages are displayed. If or is not specified in the environment or is set to the empty string, the value of is used as a default for each unspecified or empty variable. If is not specified or is set to the empty string, a default of "C" (see lang(5)) is used instead of If any internationalization variable contains an invalid setting, and behave as if all internationalization variables are set to "C". See environ(5). If is set to a non-empty string value, it overrides the values of all the other internationalization variables. International Code Set Support Single- and multi-byte character code sets are supported with the exception that do not recognize multi-byte alternative space characters. STANDARDS CONFORMANCE
expand(1)
All times are GMT -4. The time now is 01:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy