Sponsored Content
Top Forums Shell Programming and Scripting Grep and neglect a specific string Post 303015670 by RudiC on Tuesday 10th of April 2018 04:13:44 AM
Old 04-10-2018
It is usually best and most efficient for all parties to carefully phrase the request in the first place, cogitating all the possible ramifications e.g. difference in structures and positions in files. Better than letting drip in information droplet by droplet after a solution was found for the first but non-fitting sample.

The easiest way would be to force the long lines into several independent ones:
Code:
tr ' ' '\n' < file | sed ...

The logics lie in the regex: find a string of zero or more colons (parenthesized for later "back reference") then any number of non-colons, the "hope" string, non-colons again, and finally zero or more colons. Replace by the first colon if exists else the empty string (i.e. remove)
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

grep - searching for a specific string

ppl, this is my "file" with fields orderno orderdate orderdesc telno street city 1 01/04/2006 abc 123 100 tampa 2 01/04/2006 abc 123 100 tampa 3 01/04/2006 abc 123 100 tampa 4 01/04/2006 abc ... (2 Replies)
Discussion started by: manthasirisha
2 Replies

2. Shell Programming and Scripting

How To Neglect Delimiter

Hi all Iam having a text file of records seperated by "SPACE" and another text File of Records seperated by "TAB" i'm writing a Generic code for Extracting Duplicate Records Iam using "cut" Command to extract data. How Can I Neglect Delimiter And write a generic code for all cases ... (4 Replies)
Discussion started by: G.Aavudai
4 Replies

3. Shell Programming and Scripting

Remove a specific line from grep output string

Dear All I want to search string "1000" from input file and if it found i want remove line that contain 1000 and also remove 3 line above it and 2 line below it. INPUT FILE: BHAT-D 2 aaa ID CODE GS UPDATE MODE LANG MCO MCL NUMPAGES 50 ... (7 Replies)
Discussion started by: jaydeep_sadaria
7 Replies

4. Programming

How to grep the specific string or user's list from the file

I have a file on UNIX system from where I want to grep the list of all users associated to the particular repository.If the user's list is in single line then I fetch all list but if it is in two separate lines it doesn't.I use the below command a=KESTREL-DEV;b=users;cat access_file|grep... (1 Reply)
Discussion started by: rohit22hamirpur
1 Replies

5. UNIX for Dummies Questions & Answers

Grep Specific String In CSV

Hi All, I have a csv file like the following: "ABCD2","EFGH2","XXXX","1" "ABCD2","EFGH2","XXXX","2" I want to grep out the row which contains the value of 2 within the 4th column, so then i can use the extracted record to cut up and store into numerous variables. Obviously when... (3 Replies)
Discussion started by: RichZR
3 Replies

6. UNIX for Dummies Questions & Answers

How to grep cells that contain a specific string?

How do you grep cells that contain a specific string. I tried grep but it greps the whole line and not just the cells. Thanks! (4 Replies)
Discussion started by: evelibertine
4 Replies

7. UNIX for Dummies Questions & Answers

Grep contains specific string

i have file input dsgfdgdfgd> cab |egrep -i '(active|cbu)' 130502-11:34:11 10.133.1.153 9.0j stopfile=/tmp/15959 Trying password from ipdatabase file: /opt/ericsson/amos/moshell/sitefiles/ipdatabase... .. 0 1 CBU1 OFF ON 16HZ ROJ1192209/1 R5E TU8BZ04466... (3 Replies)
Discussion started by: radius
3 Replies

8. Shell Programming and Scripting

Grep string in a file and paste next line in a specific way

Hello, I know there are many questions and replies regarding grep command. What I would like to do is a bit different. File A: hello world welcome to my page this is my test site how are you I am fine, thank you where have you been I was in hospital really hope you are fine now Thanks,... (10 Replies)
Discussion started by: baris35
10 Replies

9. Shell Programming and Scripting

Grep only words containing specific string

Hello, I have two files. All urls are space seperated. source http://xx.yy.zz http://df.ss.sd.xz http://09.09.090.01 http://11.22.33 http://canada.xx.yy http://01.02.03.04 http://33.44.55 http://98.87.76.65 http://russia.xx.zz http://aa.tt.xx.zz http://1w.2e.3r.4t http://china.rr.tt ... (4 Replies)
Discussion started by: baris35
4 Replies

10. UNIX for Beginners Questions & Answers

How to use a grep search to search for a specific string within multiple directories?

Lets say I have a massive directory which is filled with other directories all filled with different c++ scripts and I want a listing of all the scripts that contain the string: "this string". Is there a way to use a grep search for that? I tried: grep -lr "this string" * but I do not... (3 Replies)
Discussion started by: Circuits
3 Replies
inet6(3N)																 inet6(3N)

NAME
inet_pton(), inet_ntop() - Internet address manipulation routines for IP Version 4 and later SYNOPSIS
DESCRIPTION
The functions and are new with IP Version 6 (IPv6) and work with both IP Version 4 (IPv4) and IPv6 addresses. The letters "p" and "n" stand for and The presentation format for an address is often an ASCII string and the numeric format is the binary value that goes into a socket address structure. The ASCII string is either the IPv4 address in dot notation or an IPv6 address in colon notation. An example of an ASCII string is or The binary value is the hex representation of the IPv4/IPv6 address. This binary value resides in the structure for IPv4 address and in the structure for IPv6 address. (Refer to the inet(3N) manpage for more details.) The functions and are opposite of each other. The function converts an ASCII address string to binary address, and the function converts a binary address into ASCII address string. Also, these are equivalent to and respectively. The inet_pton() Function The function converts an address in its standard text presentation form into its numeric binary form. The af argument specifies the family of the address. Currently, the and address families are supported. The src argument points to the IPv6/IPv4 address string being passed in. The argument points to a buffer in which the function stores the numeric address. The address is returned in network byte order. returns if the conversion succeeds, if the input is not a valid IPv4 dotted-decimal string or a valid IPv6 address string, or with errno set to if the af argument is unknown. The calling application must ensure that the buffer referred to by dst is large enough to hold the numeric address (e.g., 4 bytes for or 16 bytes for If the af argument is the function accepts a string in the standard IPv4 dotted-decimal form: ddd.ddd.ddd.ddd where ddd is a one to three digit decimal number between 0 and 255. Note that many implementations of the existing and functions accept nonstandard input: octal numbers, hexadecimal numbers, and fewer than four numbers. does not accept these formats. If the af argument is then the function accepts a string in one of the standard IPv6 text forms. (Refer to the IPv6 address notation below for more details). The inet_ntop() Function The function converts a numeric address into a text string suitable for presentation. The af argument specifies the family of the address. This can be or The src argument points to a buffer holding an IPv4 address if the af argument is or an IPv6 address if the af argument is The dst argument points to a buffer where the function will store the resulting text string. The size argument specifies the size of this buffer. The application must specify a non-NULL dst argument. For IPv6 addresses, the buffer must be at least 46-octets. For IPv4 addresses, the buffer must be at least 16-octets. In order to allow applications to easily declare buffers of the proper size to store IPv4 and IPv6 addresses in string form, the following two constants are defined in The function returns a pointer to the buffer containing the text string if the conversion succeeds, and NULL otherwise. Upon failure, errno is set to if the af argument is invalid, or if the size of the result buffer is inadequate. IPv6 Address Notation The IPv6 address is bytes long. Example of an IPv6 address is as shown below: The 128 bits are written as eight 16-bit integers separated by colons. Each integer is represented by four hexadecimal digits. In the initial stages all the 128 bits will not be used, hence, it is very likely that there will be many zeros. Hence the IP address in such a scenario will look like this: The above address can be represented in a compact fashion, by replacing a set of consecutive null 16-bit numbers by two colons. The above address can now be re-written as follows: Expanding the abbreviation is very simple. Align whatever is at the left of the double colon to the left of the address: these are the leading 16-bit words. Then align whatever is at the right of the colons to the right of the address and fill up with zeros. The double-colon convention can be used only once inside an address. To support the transition from IPv4, two special IPv6 addresses are supported. They are addresses and addresses. IPv4-Compatible Addresses Description and Example IPv4-compatible addresses can be converted to and from the older IPv4 network address format. They are used when IPv6 systems need to com- municate with each other, but are separated by an IPv4 network. IPv4-compatible addresses are formed by prepending 96 bits of zero, to a valid, 32-bit IPv4 address. For example, the IPv4 address of can be converted to the IPv6 address by first converting each decimal number separated by dots (".") to a 2-digit hexadecimal value, and concatenate into 4-digit hex values between colons (":") as listed below. In addition, leading zeros may be omitted for each hex number between the colons. Therefore, this may be written as the following IPv6 address: We can retain the dot-decimal format and re-write the above address as The above address is also a valid IPv4-compatible IPv6 address. IPv4-Mapped Addresses Description and Example IPv4-mapped addresses indicate systems that do not support IPv6. They are limited to IPv4. An IPv6 host can communicate with an IPv4-only host using the IPv4-mapped IPv6 address. IPv4-mapped addresses are formed by prepending 80 bits of zero, and 16 bits of one's, to a valid 32 bit IPv4 address. An IPv4 address of when mapped to IPv6, it becomes: or AUTHOR
These routines were developed by the University of California, Berkeley. SEE ALSO
gethostent(3N), getnetent(3N), inet(3N), hosts(4), networks(4). inet6(3N)
All times are GMT -4. The time now is 07:52 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy