Replacing UNIX 1 byte delimiters to the pipe separator


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replacing UNIX 1 byte delimiters to the pipe separator
# 1  
Old 11-30-2015
Question Replacing UNIX 1 byte delimiters to the pipe separator

Hi

I am new to Unix Shell scripting have a requirement where I have to replace the "unix 1 byte delimiter" with the "pipe" separator and also remove any carriage returns and line feeds if any

The Source File
Code:
4 QFH Jungle Hill 32-34 City Road London SE23 3UX

the output should be
Code:
4|QFH|Jungle Hill|32-34 City Road|London|SE23 3UX

Thanks

Last edited by Scrutinizer; 11-30-2015 at 01:11 PM.. Reason: need to add the command I am trying to execute; mod: code tags and removed excessive formatting
# 2  
Old 11-30-2015
Please use code tags as required by forum rules!

Any attempts/ideas/thoughts from your side?
What is the "unix 1 byte delimiter"? In your sample, I see you replace some spaces with pipes, and some not. Please describe the logics.
# 3  
Old 11-30-2015
I am trying to execute this but with no luck
Code:
sed 's/\x0/|/g' $file > $DEST_DIRNAME/${newfile%.$ORIG_FILEEXT}.$DEST_FILEEXT

---------- Post updated at 09:29 PM ---------- Previous update was at 04:51 PM ----------

I have a ASCII null separated file as shown in the example and what I am trying to do is to replace the Null separator with | (pipe) without affecting the nulls in the individual fields like "Jungle Hill" ,"City Road" & "SE23 3UX"

Last edited by vbe; 11-30-2015 at 12:56 PM.. Reason: code tags please
# 4  
Old 12-01-2015
How do you tell a "Null separator" from a "null in the individual field"? Please attach (NOT post) a decent input data sample.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Char/byte positions of delimiters in file

I have a pipe delimited file and I'm trying to write a script that will give the character/byte positions of each pipe in the file. There may be some simple way but I don't know what it is... Can someone help with this? Ex: file has output below abc|def|ghi| I want the script to tell the... (1 Reply)
Discussion started by: basz808
1 Replies

2. Shell Programming and Scripting

Replacing a column in a pipe delimited file

Hi, I have a pipe delimited file as below and I need to replace the 2nd column of each line with null values. 1|10/15/2011|fname1|lname1 2|10/15/2012|fname2|lname2 3|10/15/2013|fname3|lname3 Output file: 1||fname1|lname1 2||fname2|lname2 3||fname3|lname3 I tried this ... (2 Replies)
Discussion started by: member2014
2 Replies

3. UNIX for Dummies Questions & Answers

delimiters used in UNIX

Can you point me to information on the different delimited in UNIX like colon, spaces and tabs? (1 Reply)
Discussion started by: momhef4
1 Replies

4. Shell Programming and Scripting

Splitting text string with "|" pipe delimiters

Hi, I need to split the fields in some text strings into separate variables. The fields are separated by pipes. The strings look roughly like this: CUSTNAME|hostname|userid|gecos field|staff|disabled||SUDO Currently I can do it using something like cut -d"|" -f1, but when I put that into... (4 Replies)
Discussion started by: alanp36
4 Replies

5. Shell Programming and Scripting

Validating Separator in unix

Hi I have an input CSV file which contains some values Format of file is as follows: 32R01000000003144476;32R01000000029054270;1000;6000;12/12/2007;0382521276;REG;Régulari I just need to validate it whether it is ';' seperated ie (if any other seperator is used it shld give an error) How do... (5 Replies)
Discussion started by: theeights
5 Replies

6. UNIX for Dummies Questions & Answers

replacing space with pipe(delimiter)

Hello All, I have a file with thousands of records: eg: |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... (6 Replies)
Discussion started by: OSD
6 Replies

7. UNIX for Dummies Questions & Answers

Replacing a field in pipe delimited TEXT File

Hi, I want to replace a field in a text delimited file with the actual number of records in the same file. HDR|ABCD|10-13-2008 to 10-19-2008.txt|10-19-2008|XYZ DTL|0|5464-1|0|02-02-2008|02-03-2008||||F||||||||| DTL|1|5464-1|1|02-02-2008|02-03-2008|1||JJJ... (3 Replies)
Discussion started by: ravi0435
3 Replies

8. Shell Programming and Scripting

Check if 2 files are identical byte-to-byte?

In my server migration requirement, I need to compare if one file on old server is exactly the same as the corresponding file on the new server. For diff and comm, the inputs need to be sorted. But I do not want to disturb the content of the file and need to find byte-to-byte match. Please... (4 Replies)
Discussion started by: krishmaths
4 Replies

9. UNIX for Dummies Questions & Answers

Help with unix separator

can some one give me a list of unix separtor(s) if one than just the separator please thank you. (2 Replies)
Discussion started by: Black mage2021
2 Replies
Login or Register to Ask a Question