Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Replace Delimiters with Space Post 302850039 by Don Cragun on Tuesday 3rd of September 2013 09:31:15 PM
Old 09-03-2013
Quote:
Originally Posted by mora
Hi All,
How to Replace the delimiter for a particular field. I have used awk to replace the field values based on the position, but I tried to remove/replace delimiters with space on particular positions.

I tried tr command with combination of awk not sure if this is the correct way, but I am not getting the required output. Is there any other way we can achieve this.

Code:
Sample text 1.

Data| 12345|U|76834

I want to replace the second and fourth pipe delimiter with space

Regards,
Mora.
Moderator's Comments:
Mod Comment Use CODE tags; not HTML tags to display sample input, output, and code samples.
I'm confused. You have 3 pipe delimiters and you want to change the 2nd and 4th???

Do all input lines have the same number of pipe delimiters?

Please show us sample input that matches your description of what you want to do AND show us sample output corresponding to that input.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

replace space by _

Hi I need to know how I change the spaces by _ in folders and filder founded by find ex. find . -name "* *" -exec echo {} \; ./test space ./test space/new file.txt ./test space/new file ./test space/untitled folder ./test space/untitled folder/new fileruben ./Backup/backup/Image... (6 Replies)
Discussion started by: ruben.rodrigues
6 Replies

2. Shell Programming and Scripting

Replace space

Hai masters, If a file contains content of 2000 lines, from which i need to remove the first n characters or first n spaces from each line of the file. If suppose to remove n characters or first n spaces from a single line means, just use the command nx. But from the above scenario,... (9 Replies)
Discussion started by: ecearund
9 Replies

3. Shell Programming and Scripting

Replace long space to become one space?

Hi, i have the log attached. Actually i want the long space just become 1 space left like this : Rgds, (12 Replies)
Discussion started by: justbow
12 Replies

4. Shell Programming and Scripting

Replace every other space

I'd like a sed command to replace every other space in my file. File: 0 1 0 3 0 2 0 5 Want: 01 03 02 05 Does anyone have any ideas? (9 Replies)
Discussion started by: peanuts48
9 Replies

5. Shell Programming and Scripting

Processing data that contains space and quote delimiters

I need to write a Bash script to process a data file that is in this format: 1 A B C D E 2 F G "H H" I J As you can see, the data is delimited by a space, but there are also some fields that contain spaces and are surrounded by double-quotes. An example of that is "H H". I wrote... (7 Replies)
Discussion started by: RickS
7 Replies

6. UNIX for Dummies Questions & Answers

Remove two delimiters, space and double quotes

I would like to know how to replace a space delimiter with a ^_ (\037) delimiter and a double quote delimiter while maintaining the spaces inside the double quotes. The double quote delimiter is only used on text fields. I'd prefer a one-liner, but could handle a function or script that accepts... (4 Replies)
Discussion started by: SteveDWin
4 Replies

7. Shell Programming and Scripting

How to Replace string between delimiters?

Basically , i want to delete strings of a particular pattern from the flat file which is " | " pipe delimited. Below are the valid formats : 1) AAA (0) 111-111-111, AAA, BB 2) AAA (0) 111-111-1111;X, AAA, BB original flat file example : |ABC ABC XHAMK|AAA (0) 111-111-111, AAA,... (3 Replies)
Discussion started by: Ravi_007
3 Replies

8. Shell Programming and Scripting

Extract value between the delimiters and replace it with another value

Hi All, i have file name like below ABC_065224_123456_123456_your_130413_163005.txt ABC_065224_123456_MAIN_20130413_163005.txt ABC_065224_123456_123456_MAIN_130413_163005.txt ABC_065224_123456_123456_434567_MAIN_130413_163005.txt i need to find out the number of characters in the filed... (6 Replies)
Discussion started by: dssyadav
6 Replies

9. Shell Programming and Scripting

How to replace string between delimiters?

Hello, I would need to replace a delimiter in a flat file using.I would like to replace the semicolon (";") but only if it was contained in a string between quotes. For example: Original flat file example: abc;abc;"abc;abc";cd;"ef;ef";abc aa;bb;"aa";cc;"ddd;eee";ff Desired output:... (9 Replies)
Discussion started by: bartleby
9 Replies

10. Programming

find & Replace text using two non-unique delimiters.

I can find and replace text when the delimiters are unique. What I cannot do is replace text using two NON-unique delimiters: Ex., "This html code <text blah >contains <garbage blah blah >. All tags must go,<text > but some must be replaced with <garbage blah blah > without erasing other... (5 Replies)
Discussion started by: bedtime
5 Replies
JOIN(1) 						      General Commands Manual							   JOIN(1)

NAME
join - relational database operator SYNOPSIS
join [ options ] file1 file2 DESCRIPTION
Join forms, on the standard output, a join of the two relations specified by the lines of file1 and file2. If file1 is `-', the standard input is used. File1 and file2 must be sorted in increasing ASCII collating sequence on the fields on which they are to be joined, normally the first in each line. There is one line in the output for each pair of lines in file1 and file2 that have identical join fields. The output line normally con- sists of the common field, then the rest of the line from file1, then the rest of the line from file2. Fields are normally separated by blank, tab or newline. In this case, multiple separators count as one, and leading separators are dis- carded. These options are recognized: -an In addition to the normal output, produce a line for each unpairable line in file n, where n is 1 or 2. -e s Replace empty output fields by string s. -jn m Join on the mth field of file n. If n is missing, use the mth field in each file. -o list Each output line comprises the fields specified in list, each element of which has the form n.m, where n is a file number and m is a field number. -tc Use character c as a separator (tab character). Every appearance of c in a line is significant. SEE ALSO
sort(1), comm(1), awk(1) BUGS
With default field separation, the collating sequence is that of sort -b; with -t, the sequence is that of a plain sort. The conventions of join, sort, comm, uniq, look and awk(1) are wildly incongruous. 7th Edition April 29, 1985 JOIN(1)
All times are GMT -4. The time now is 04:14 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy