Sponsored Content
Top Forums UNIX for Dummies Questions & Answers replacing space with pipe(delimiter) Post 302287922 by OSD on Monday 16th of February 2009 03:19:49 AM
Old 02-16-2009
The sed command does not modify the result:

the output remains the same:
|000222|123456987|||||||AARONSON| JOHN P|||PRIMARY |P
|000111|567894521|||||||ATHENS| WILLIAM k|||AAAA|L

expected:|000222|123456987|||||||AARONSON| JOHN |P|||PRIMARY |P
|000111|567894521|||||||ATHENS| WILLIAM |k|||AAAA|L

i need a pipe delimiter after john and william. there are many more records ith diffrent name. Actually, john=first name and P=initial. I need to separate these two fields with a pipe.Hope i am more clear.thanks in advance.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Cutting a portion of a line seperated by pipe delimiter

Hi, In the below line a|b|10065353|tefe|rhraqs|135364|5347575 dgd|rg|4333|fhra|grhrt|46423|urdsgd Here i want to cut the characters in between the second and third pipe delimiter and then between fifth and sixth delimiter and retain the rest of the line. My output should be ... (3 Replies)
Discussion started by: ragavhere
3 Replies

2. Shell Programming and Scripting

comma delimiter and space

I have a csv file and there is a problem which I need to resolve. Column1,Column2,Colum3,Column4 ,x,y,z ,d,c,v t,l,m,n ,h,s,k ,k,,y z,j, ,p Now if you see column1 for row 1 and row 4 though they are null there is a space but in case of row2 and row 5 there is no space. I want row... (3 Replies)
Discussion started by: RubinPat
3 Replies

3. Shell Programming and Scripting

Space as a delimiter

not sure if i'm doing this right i'm new tho this but i'm trying to use a space as a delimiter with the cut command my code is size=$( du -k -S -s /home/cmik | cut -d' ' -f1 ) i've also tried -f2 and switching the -d and -f around if that does anything (3 Replies)
Discussion started by: Cmik
3 Replies

4. Shell Programming and Scripting

Replacing Comma delimiter coming inside the data.

Hello, I am having flat file (Comma Delimiter) and the data in the file is as given below. EMPNO, ENAME, DESIGNATION, SALARY 10979, Arun Kumar, Cosultant, 35000 13555, Bidhu Shekar, Senior Consultant, 45000 15000, Kiran, Kumar, Senior, Consultant, 40000 If... (9 Replies)
Discussion started by: arunvasu2
9 Replies

5. UNIX for Dummies Questions & Answers

[Solved] How to swap PIPE seperator delimiter?

I have file like below 1|4|OR|OLAP|INT|INT||CONSTANT|2012/08/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|55791|LNR| 2|4|OR|OLAP|CLR|CLR||CONSTANT|2012/09/07|9999/12/31|0|0|0|0|PRL|-358.1684563||||||||||36522|57891|REGS|... (2 Replies)
Discussion started by: gkskumar
2 Replies

6. Red Hat

Converting fixed width file to pipe delimiter in Linux(red-hat)

Hi, I am facing a typical scenario for AWK command . In HP- UNIX is behave as expected but in red hat linux same awk code is not give the same result. The below code is for convert the fixed width file to pipe delimiter file in HP-unix server. awk code: #!/bin/awk -f NR!=1... (11 Replies)
Discussion started by: brij_abhi
11 Replies

7. Shell Programming and Scripting

Removing duplicate lines on first column based with pipe delimiter

Hi, I have tried to remove dublicate lines based on first column with pipe delimiter . but i ma not able to get some uniqu lines Command : sort -t'|' -nuk1 file.txt Input : 38376KZ|09/25/15|1.057 38376KZ|09/25/15|1.057 02006YB|09/25/15|0.859 12593PS|09/25/15|2.803... (2 Replies)
Discussion started by: parithi06
2 Replies

8. Shell Programming and Scripting

Problem in using cut command with pipe as a delimiter while using in a script

There is a text file in my project named as "mom.txt" in which i want to have contents like.................. LSCRM(Application Name): 1: This is my first application. 2: Today we did shell scripting automation for this app. 3: It was really a good fun in doing so. 4: Really good.| (Here i... (7 Replies)
Discussion started by: Abhijeet Anand
7 Replies

9. Shell Programming and Scripting

Replace CRLF between pipe (|) delimiter with LF

Hi Folks! Need a solution for the following :- Source data ------------- 123|123|<CRLF><CRLF><CRLF>|321<CRLF> Required output ------------------ 123|123|<LF><LF><LF>|321<CRLF> <CRLF> represents carriage return <LF> represents line feed Being hunting high and low for a... (10 Replies)
Discussion started by: hishamzz
10 Replies

10. Shell Programming and Scripting

Replace delimiter for a particular column in a pipe delimited file

I have an input file as below Emp1|FirstName|MiddleName|LastName|Address|Pincode|PhoneNumber 1234|FirstName1|MiddleName2|LastName3| Add1 || ADD2|123|000000000 Output : 1234|FirstName1|MiddleName2|LastName3| Add1 ,, ADD2|123|000000000 OR 1234,FirstName1,MiddleName2,LastName3, Add1 ||... (2 Replies)
Discussion started by: styris
2 Replies
getipnodebyname(3)					     Library Functions Manual						getipnodebyname(3)

NAME
getipnodebyname - Get a network host entry by name for a specific address family LIBRARY
Standard C Library (libc.so, libc.a) SYNOPSIS
#include <netdb.h> struct hostent *getipnodebyname( const char *name, int addr_family, int flags, int *error_num); PARAMETERS
Specifies the official network node name, alias, or numeric node address (for example, a IPv4 dotted-decimal address or an IPv6 hexadecimal address). Specifies the address family. This can be AF_INET for IPv4 addresses or AF_INET6 for IPv6 addresses. Specifies the type of addresses for which to search and the types of addresses that are returned. See the "Nodename-to-Address Processing" section. Specifies an error return code value if the function is not successful. See the ERRORS section for a description of the values. DESCRIPTION
The use of this routine is deprecated. Use the getaddrinfo(3) routine instead; it is also protocol-independent. The getipnodebyname() routine is an evolution of the gethostbyname() routine that enables name lookups in address families other than AF_INET. The getipnodebyname() routine returns a pointer to a structure of type hostent. Its members specify data obtained from the local /etc/ipn- odes file, /etc/hosts file, or one of the files distributed by DNS/BIND or NIS. If multiple addresses are found, the h_addr_list field in the hostent structure contains the addresses. To determine which file or files to search, and in which order, the system uses the switches in the /etc/svc.conf file. The netdb.h header file defines the hostent structure. If using DNS/BIND, the information is obtained from a name server specified in the /etc/resolv.conf file. When the name server is not run- ning, the getipnodebyname() routine searches the local ipnodes name file for IPv6 and IPv4 addresses and the hosts name file for IPv4 addresses, if none are found in the ipnodes file. If the name parameter does not contain a dot "." and you are using DNS/BIND, the getipnodebyname() routine checks whether the environment variable HOSTALIASES is set. If set, it first searches the file named by HOSTALIASES for an alias matching the name parameter. If HOSTAL- IASES is not set, the routine uses the default domain. The alias file has the following format: name1 name2 The alias name. This name cannot include dots. The host name used by DNS/BIND to look up the node information. The hosts database must be distributed by DNS/BIND. The getipnodebyname() routine dynamically allocates the hostent structure. Use the freehostent() routine to free the allocated memory. Nodename-to-Address Processing A following is a list of the flags parameters and how the processing is affected by the value of the af parameters: If the af value is AF_INET, the routine searches for A records. If found, returns IPv4 addresses (h_length=4). If no A records are found, returns a NULL pointer. Provides backward compatibility for existing IPv4 applications. If the af value is AF_INET6, searches for AAAA records. If found, returns IPv6 records (h_length=16). If no AAAA records are found, returns a NULL pointer. If the af value is AF_INET, this is ignored. If the af value is AF_INET6, searches for AAAA records. If found, returns IPv6 records (h_length=16). If no AAAA records are found, searches for A records. If found, returns IPv4-mapped IPv6 addresses (h_length=16). If no records are found, returns a NULL pointer. If the af value is AF_INET, this is ignored. If the af value is AF_INET6, searches for AAAA records. If found, returns IPv6 addresses (h_length=16). Then, searches for A records. If found, returns IPv4-mapped IPv6 addresses (h_length=16). If no records are found, returns a NULL pointer. You can use the flags in any combination to achieve finer control of the translation process. The AI_ADDRCONFIG flag is typically used in combination with other flags to modify the search based on the source address or addresses configured on the system. The following list describes how the AI_ADDRCONFIG flags works by itself. If an IPv4 source address is configured, searches for A records. If an IPv6 source address is configured, searches for AAAA records. Most applications will want to use the combination of the AI_ADDRCONFIG and AI_V4MAPPED flags to control their search. To simplify this for the programmer, the AI_DEFAULT symbol, which is a logical OR of AI_ADDRCONFIG and AI_V4MAPPED, is defined. The following list describes how AI_DEFAULT directs the search. If the af value is AF_INET, searches for A records only if an IPv4 source address is configured on the sys- tem. If found, returns IPv4 addresses (h_length=4). If no A records are found, returns a NULL pointer. If the af value is AF_INET6, searches for AAA records only if an IPv6 source address is configured on the system. If found, returns IPv6 addresses (h_length=16). If no AAAA records are found and if an IPv4 address is configured on the system, searches for A records. If found, returns IPv4-mapped IPv6 addresses. If no records are found, returns a NULL pointer. EXAMPLES
For IPv4 applications (backward compatibility), use the following syntax: getipnodebyname(address, AF_INET, 0, &error_num); RETURN VALUES
Upon successful completion, the getipnodebyname() routine returns a pointer to a hostent structure. If it reaches the end of the network hostname database, it returns a null pointer. ERRORS
If the getipnodebyname() routine call fails, error_num is set to one of the following the values: The name you have used is not an official node name or alias; another type of name server request may be successful. The server recognized the request and the name, but no address is available for the name. Another type of name server request may be successful. An unexpected server failure occurred. This is a non- recoverable error. A transient error occurred, for example, the server did not respond. A retry at some later time may be successful. FILES
The Internet network node name database. Each record in the file occupies a single line and has three fields consisting of the node address (IPv6 or IPv4), official node name, and aliases. The Internet network hostname database. Each record in the file occupies a sin- gle line and has three fields consisting of the host IPv4 address, official hostname, and aliases. The resolver configuration file. The database service selection configuration file. RELATED INFORMATION
Functions: endhostent(3), freehostent(3), getaddrinfo(3), getipnodebyaddr(3), sethostent(3). Files: hostname(5), resolv.conf(4), svc.conf(4). Networks: bind_intro(7), nis_intro(7). delim off getipnodebyname(3)
All times are GMT -4. The time now is 11:35 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy