Sponsored Content
Top Forums Shell Programming and Scripting sed help, Find a pattern, replace it with same text minus leading 0 Post 302669043 by bakunin on Tuesday 10th of July 2012 10:56:32 AM
Old 07-10-2012
You need the "\(...\)" device for this. This way you can replicate parts of the matched regexp in the substitution:

Code:
sed 's/0\([0-9]\)/\1/'

will replace any "0" followed by a digit with this digit and omit the leading "0".

I hope this helps.

bakunin
This User Gave Thanks to bakunin For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Find a pattern and replace using sed.

Hi I need to help on finding the below pattern using sed <b><a href="/home/document.do?assetkey=x-y-abcde-1&searchclause=photo"> and replace as below in the same line on the index file. <b><a href="/abcde.html"> thx in advance. Mari (5 Replies)
Discussion started by: maridhasan
5 Replies

2. Shell Programming and Scripting

sed: Find start of pattern and extract text to end of line, including the pattern

This is my first post, please be nice. I have tried to google and read different tutorials. The task at hand is: Input file input.txt (example) abc123defhij-E-1234jslo 456ujs-W-abXjklp From this file the task is to grep the -E- and -W- strings that are unique and write a new file... (5 Replies)
Discussion started by: TestTomas
5 Replies

3. Shell Programming and Scripting

pattern replace inside text file using sed

Hi, I have a situation where I want to replace some occurrences of ".jsp" into ".html" inside a text file. For Example: If a pattern found like <a href="http://www.mysite.com/mypage.jsp"> it should be retained. But if a pattern found like <a href="../mypage.jsp"> it should be changed to... (4 Replies)
Discussion started by: meharo
4 Replies

4. Shell Programming and Scripting

sed to find replace mutliline text

Hi, My input file form 1 fill 2 fill 3 form 4 fill 5 form 6 fill 7 form 8 Now i need to substiute according to the fill. form followed by single fill need to be replced with category 1 form with above and below fill need to be repalced with category 2 (5 Replies)
Discussion started by: vasanth.vadalur
5 Replies

5. Shell Programming and Scripting

find pattern and replace the text before it

i am editing a big log file with the following pattern: Date: xxxx Updated: name Some log file text here Date: eee Updated: ny Some log file text here Basically i want to remove all the text in a line before the "Updated" pattern. I sill want to print the other... (4 Replies)
Discussion started by: balan1983a
4 Replies

6. Shell Programming and Scripting

Sed command to replace with pattern except for text and closing parentheses

Can someone help me with a sed command: There will be multiple occurences in a file that look like this: MyFunction(12c34r5) and I need to replace that with just the 12c34r5 for every occurrence. The text between the parentheses will be different on each occurrence, so I can't search for that.... (4 Replies)
Discussion started by: missb
4 Replies

7. Shell Programming and Scripting

sed find/replace a pattern, but not this one..

I've got a file like so: ...lots of lines, etc. push "route 10.8.0.0 255.255.255.0" push "route 192.168.1.123 255.255.255.0" ...lots of lines, etc. I want to sed find/replace the IP address in the second line, whatever it is, with a new IP address, but I don't want to touch the first line.... (5 Replies)
Discussion started by: DaHai
5 Replies

8. Shell Programming and Scripting

Pattern replace from a text file using sed

I have a sample text format as given below <Text Text_ID="10155645315851111_10155645333076543" From="460350337461111" Created="2011-03-16T17:05:37+0000" use_count="123">This is the first text</Text> <Text Text_ID="10155645315851111_10155645317023456" From="1626711840902323"... (3 Replies)
Discussion started by: my_Perl
3 Replies

9. Shell Programming and Scripting

sed -- Find pattern -- print remainder -- plus lines up to pattern -- Minus pattern

The intended result should be : PDF converters 'empty line' gpdftext and pdftotext?xml version="1.0"?> xml:space="preserve"><note-content version="0.1" xmlns:/tomboy/link" xmlns:size="http://beatniksoftware.com/tomboy/size">PDF converters gpdftext and pdftotext</note-content>... (9 Replies)
Discussion started by: Klasform
9 Replies

10. UNIX for Beginners Questions & Answers

Find pattern and replace using sed

Hi, i want to replace the following lines in such a way that if the word merge exists in first column it must replace the 3rd column as M and if parse exists in first column then the last column must P, if neither it must mark it as X. I have tried the solution using awk, but it is saying... (6 Replies)
Discussion started by: charlie87
6 Replies
udc(4)							     Kernel Interfaces Manual							    udc(4)

NAME
udc - user-defined character raster font format DESCRIPTION
The UDC raster font format consists of a character index and character pattern. The code area and the maximum number of characters depend upon the device and the language. The size of the fonts depend upon the merged font file and the device. Character Index The character index consists of a 4- or 5-digit code. According to the languese, the following codes can be used: +--------------------+------------+ | Language | Code | +--------------------+------------+ |Japanese | KU-TEN | |Korean | Row&Column | |Simplified Chinese | HP-15 | |Traditional Chinese | HP-15 | +--------------------+------------+ For KU-TEN code, the 2- or 3-digit KU code and 2-digit TEN code, i.e. 4- or 5-digit code is used. There are two pattern format as follow- ing. Note 1KU ~ 120KU are valid for JIS X 0208, and 1KU ~ 94KU are for JIS X 0212. +------------------------+-----------------------------+ |Character Index example | | +------------------------+-----------------------------+ |[8701] | For JIS X 0208 (87KU 01TEN) | |[8701-0212] | For JIS X 0212 (87KU 01TEN) | +------------------------+-----------------------------+ For Row&Column code, the 4-digit decimal code is used. The code is contained in brackets in this form: [1601]. For HP-15 code, the alphanumeric 0x precedes the 4-digit hexadecimal code as in 0x889F. Character Pattern The # character in the illustrations below represents black pixels. A space represents a white pixel. EXAMPLES
[9493] # # # # # # # # # [9494] ##### # # # # # # # # ##### SEE ALSO
udcc(1), udcload(1), xudced(1). udc(4)
All times are GMT -4. The time now is 06:43 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy