Sponsored Content
Full Discussion: Regular expression with sed
Top Forums Shell Programming and Scripting Regular expression with sed Post 302249431 by nervous on Tuesday 21st of October 2008 10:14:10 AM
Old 10-21-2008
Thanks for your answers, last solution is perfect, I need some more assistance, file format is as follows:
Code:
ADMDN13EX84447619,"HUMMER H3 SUV, LEATHER SEAT",XAWBG020209,m,Kuwaiti,M,13/05/1969,39,Block Building

I need XAWBG020209 from this line, I can't use awk because sometimes XA string is in the third column, my part numbers are starting with XA or XG, I want to take these part numbers then lookup in another file acc.csv which contains the description of these parts, I want to match part number extracted from this line with that part number and show the description, I wanted to do it by myself but since 3 hours I'm not able to figure out anything.

Second file is properly formatted, few lines from that file are as follows:
Code:
XG96470024,04-05OP WHEEL (ALLOY)
XG96545706,05OP SPOILER A-RR# HB
XG96635210,EPICA SPOILER KIT-V250
XG96635230,EPICA BODY KIT-V250
XG96654234,"AVEO TIP A-EXHAUST,TAIL - T -2"
XG96664463,07EP BLUETOOTH
XG96806104,07EP REAR SPOILER
XG96806220,07EP BODY KIT
XG96816783,07EP EXHAUST TIP
XGCHCAP71,CHROME PACKAGE CAPRICE 08

Your help would be appreciated.

Last edited by nervous; 10-21-2008 at 11:19 AM..
 

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Regular expression with SED

Hi! I'm trying to write a regexp but I have no luck... I have a string like this: param1=sometext&param2=hello&param3=bye Also, the string can be simply: param2=hello I want to return the value of param2: "hello". How can I do this? Thanks. (3 Replies)
Discussion started by: GagleKas
3 Replies

2. Shell Programming and Scripting

Regular expression (sed)

Hi I need to get text that are within "" For example File: asdasd "test test2" sadasds asdda asdasd "demo demo2" Output: test test2 demo demo2 Any help is good Thank you (12 Replies)
Discussion started by: blito_loco
12 Replies

3. Shell Programming and Scripting

sed regular expression help

please consider this: echo "11111*X*005010X279~ST*270*1111111*005010X279~BHT*0011*11" | sed 's/.*\(005010X(\d)(\d)(\d)*\).*$/\1/'i'm searching for first occurrence of 005010X while leaving rest of characters out. :confused: any tips? thnx in advance guys. (7 Replies)
Discussion started by: grep01
7 Replies

4. UNIX for Dummies Questions & Answers

Regular Expression In Sed

Hi , I am learing sed echo abc 123 def 456 | sed 's|\(*\) \(*\)|\1|' is returning abc def 456 i was hoping abc def "\1" should only print the occurence of the first pattern but according to my understanding it is just removing the first occurence of the second pattern... (7 Replies)
Discussion started by: max_hammer
7 Replies

5. Programming

Perl: How to read from a file, do regular expression and then replace the found regular expression

Hi all, How am I read a file, find the match regular expression and overwrite to the same files. open DESTINATION_FILE, "<tmptravl.dat" or die "tmptravl.dat"; open NEW_DESTINATION_FILE, ">new_tmptravl.dat" or die "new_tmptravl.dat"; while (<DESTINATION_FILE>) { # print... (1 Reply)
Discussion started by: jessy83
1 Replies

6. Shell Programming and Scripting

Help with sed regular expression

Hi all, I want to get a substring from a string based on given delimiter, for example: str="foo|bar|baz" with delimiter "|", I want to get one substring at each time with the order number the substring in the whole string, given 1 to get "foo", given 2 to get "bar", given 3 to get "baz", I... (2 Replies)
Discussion started by: Roy987
2 Replies

7. UNIX for Advanced & Expert Users

sed: -e expression #1, char 0: no previous regular expression

Hello All, I'm trying to extract the lines between two consecutive elements of an array from a file. My array looks like: problem_arr=(PRS111 PRS213 PRS234) j=0 while } ] do k=`expr $j + 1` sed -n "/${problem_arr}/,/${problem_arr}/p" problemid.txt ---some operation goes... (11 Replies)
Discussion started by: InduInduIndu
11 Replies

8. Shell Programming and Scripting

I am learning regular expression in sed,Please help me understand the use curly bracket in sed,

I am learning SED and just following the shell scripting book, i have trouble understanding the grep and sed statement, Question : 1 __________ /opt/oracle/work/antony>cat teledir.txt jai sharma 25853670 chanchal singhvi 9831545629 anil aggarwal 9830263298 shyam saksena 23217847 lalit... (7 Replies)
Discussion started by: Antony Ankrose
7 Replies

9. Shell Programming and Scripting

sed regular expression

Hi , I need to remove pipe character from a |^ delimeted file. Something like |^tran|sformers||^|revenge |of fallen|^ to |^transformers|^revenge of fallen|^... Cold anybody please help to build the regular expression using sed . many thanks. Please use code tags next time for... (1 Reply)
Discussion started by: kokjek
1 Replies
PROTOCOLS(5)						     Linux Programmer's Manual						      PROTOCOLS(5)

NAME
protocols - protocols definition file DESCRIPTION
This file is a plain ASCII file, describing the various DARPA internet protocols that are available from the TCP/IP subsystem. It should be consulted instead of using the numbers in the ARPA include files, or, even worse, just guessing them. These numbers will occur in the protocol field of any IP header. Keep this file untouched since changes would result in incorrect IP packages. Protocol numbers and names are specified by the IANA (Inter- net Assigned Numbers Authority). Each line is of the following format: protocol number aliases ... where the fields are delimited by spaces or tabs. Empty lines are ignored. If a line contains a hash mark (#), the hash mark and the part of the line following it are ignored. The field descriptions are: protocol the native name for the protocol. For example ip, tcp, or udp. number the official number for this protocol as it will appear within the IP header. aliases optional aliases for the protocol. This file might be distributed over a network using a network-wide naming service like Yellow Pages/NIS or BIND/Hesiod. FILES
/etc/protocols The protocols definition file. SEE ALSO
getprotoent(3) <http://www.iana.org/assignments/protocol-numbers> COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2012-08-05 PROTOCOLS(5)
All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy