Sponsored Content
Top Forums Shell Programming and Scripting Using sed to replace specific character and specific position Post 302360889 by tjmannonline on Sunday 11th of October 2009 07:31:32 AM
Old 10-11-2009
can sed do this beyond 255 chars ? for example, i want to replace at position 500.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

using sed to replace a specific string on a specific line number using variables

using sed to replace a specific string on a specific line number using variables this is where i am at grep -v WARNING output | grep -v spawn | grep -v Passphrase | grep -v Authentication | grep -v '/sbin/tfadmin netguard -C'| grep -v 'NETWORK>' >> output.clean grep -n Destination... (2 Replies)
Discussion started by: todd.cutting
2 Replies

2. Shell Programming and Scripting

Insert character in a specific position of a file

Hi, I need to add Pipe (|) at 5th and 18th position of all records a file. How can I do this? I tried to add it at 5th position using the below code. It didnt work. Please help!!! awk '{substr($0,5,1) ~ /|/}{print}' $input_file > $temp_file (1 Reply)
Discussion started by: gpaulose
1 Replies

3. Shell Programming and Scripting

how to replace specific character , if possible using sed

My script is extracting data from SQl session, however sometimes the result contains one or multiple space after/before any numerical value. e,g . "123","1 34","1 3 45", "43 5" How to remove these unwanted spaces..so that I can get the following result : "123","134",1345","435" (1 Reply)
Discussion started by: mady135
1 Replies

4. Shell Programming and Scripting

Sed position specific replace

I'm drawing a blank on how to use sed to replace selectively based on position in the string (vs nth occurence): hello.|there.|how.|are.|you.| I want the period removed in the 3rd item (as defined by the pipe delimiter) if a period is present. So the result in this case would be: ... (2 Replies)
Discussion started by: tiggyboo
2 Replies

5. Shell Programming and Scripting

Using sed to replace a string in a specific position

I asked this before, but my problem got more complicated. Heres what I am trying to do: I'm trying to replace a string at a certain location with another string. Heres the file I'm trying to change: \E I want to replace the escape code at the 3rd line, 2nd column with this escape code... (3 Replies)
Discussion started by: tinman47
3 Replies

6. Shell Programming and Scripting

Replace specific field on specific line sed or awk

I'm trying to update a text file via sed/awk, after a lot of searching I still can't find a code snippet that I can get to work. Brief overview: I have user input a line to a variable, I then find a specific value in this line 10th field in this case. After asking for new input and doing some... (14 Replies)
Discussion started by: crownedzero
14 Replies

7. Shell Programming and Scripting

Delete character on specific position

Hi, im still new in unix. i want to ask how to delete character on specific position in line, lets say i want to remove 5 character from position 1000, so characters from position 1000-1005 will be deleted. i found this sed command can delete 4 characters from position 10, but i dont know if... (7 Replies)
Discussion started by: bluesue
7 Replies

8. Linux

Removing a character at specific position in a column

Hi, I have a file like this (about 8 columns in total, this being the 2nd column) gi_49482297_ref_YP_039521.1_ gi_49482297_ref_YP_039521.1_ gi_49482315_ref_YP_039539.1_ gi_49482315_ref_YP_039539.1_I want to remove the _ at the end of the line. And at later stages I would want to replace the... (5 Replies)
Discussion started by: Syeda Sumayya
5 Replies

9. Post Here to Contact Site Administrators and Moderators

Search for a pattern and replace a space at specific position with a Character in File

In file, we have millions of records each of 1000 in length. And at specific position say 800 there is a space, we need to replace it with Character X if the ID in that row starts with 123. So far i have used the below which is replacing space at that position to X but its not checking for... (3 Replies)
Discussion started by: Jagmeet Singh
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
URI::Escape(3)						User Contributed Perl Documentation					    URI::Escape(3)

NAME
URI::Escape - Percent-encode and percent-decode unsafe characters SYNOPSIS
use URI::Escape; $safe = uri_escape("10% is enough "); $verysafe = uri_escape("foo", "-377"); $str = uri_unescape($safe); DESCRIPTION
This module provides functions to percent-encode and percent-decode URI strings as defined by RFC 3986. Percent-encoding URI's is informally called "URI escaping". This is the terminology used by this module, which predates the formalization of the terms by the RFC by several years. A URI consists of a restricted set of characters. The restricted set of characters consists of digits, letters, and a few graphic symbols chosen from those common to most of the character encodings and input facilities available to Internet users. They are made up of the "unreserved" and "reserved" character sets as defined in RFC 3986. unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" reserved = ":" / "/" / "?" / "#" / "[" / "]" / "@" "!" / "$" / "&" / "'" / "(" / ")" / "*" / "+" / "," / ";" / "=" In addition, any byte (octet) can be represented in a URI by an escape sequence: a triplet consisting of the character "%" followed by two hexadecimal digits. A byte can also be represented directly by a character, using the US-ASCII character for that octet. Some of the characters are reserved for use as delimiters or as part of certain URI components. These must be escaped if they are to be treated as ordinary data. Read RFC 3986 for further details. The functions provided (and exported by default) from this module are: uri_escape( $string ) uri_escape( $string, $unsafe ) Replaces each unsafe character in the $string with the corresponding escape sequence and returns the result. The $string argument should be a string of bytes. The uri_escape() function will croak if given a characters with code above 255. Use uri_escape_utf8() if you know you have such chars or/and want chars in the 128 .. 255 range treated as UTF-8. The uri_escape() function takes an optional second argument that overrides the set of characters that are to be escaped. The set is specified as a string that can be used in a regular expression character class (between [ ]). E.g.: "x00-x1fx7f-xff" # all control and hi-bit characters "a-z" # all lower case characters "^A-Za-z" # everything not a letter The default set of characters to be escaped is all those which are not part of the "unreserved" character class shown above as well as the reserved characters. I.e. the default is: "^A-Za-z0-9-._~" uri_escape_utf8( $string ) uri_escape_utf8( $string, $unsafe ) Works like uri_escape(), but will encode chars as UTF-8 before escaping them. This makes this function able to deal with characters with code above 255 in $string. Note that chars in the 128 .. 255 range will be escaped differently by this function compared to what uri_escape() would. For chars in the 0 .. 127 range there is no difference. Equivalent to: utf8::encode($string); my $uri = uri_escape($string); Note: JavaScript has a function called escape() that produces the sequence "%uXXXX" for chars in the 256 .. 65535 range. This function has really nothing to do with URI escaping but some folks got confused since it "does the right thing" in the 0 .. 255 range. Because of this you sometimes see "URIs" with these kind of escapes. The JavaScript encodeURIComponent() function is similar to uri_escape_utf8(). uri_unescape($string,...) Returns a string with each %XX sequence replaced with the actual byte (octet). This does the same as: $string =~ s/%([0-9A-Fa-f]{2})/chr(hex($1))/eg; but does not modify the string in-place as this RE would. Using the uri_unescape() function instead of the RE might make the code look cleaner and is a few characters less to type. In a simple benchmark test I did, calling the function (instead of the inline RE above) if a few chars were unescaped was something like 40% slower, and something like 700% slower if none were. If you are going to unescape a lot of times it might be a good idea to inline the RE. If the uri_unescape() function is passed multiple strings, then each one is returned unescaped. The module can also export the %escapes hash, which contains the mapping from all 256 bytes to the corresponding escape codes. Lookup in this hash is faster than evaluating "sprintf("%%%02X", ord($byte))" each time. SEE ALSO
URI COPYRIGHT
Copyright 1995-2004 Gisle Aas. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.16.2 2012-02-11 URI::Escape(3)
All times are GMT -4. The time now is 08:05 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy