Using
on the file I can remove max 4 new lines on the 4th field.
The delimiter used is ^| which is at the end of the 4th field.
Now I must replace the "|" between the "^"...
---------- Post updated at 12:15 PM ---------- Previous update was at 09:47 AM ----------
I have come to the:
but this replaces all "|" till the end... how can I tell awk to stop replacing at first "^|"?
---------- Post updated at 04:19 PM ---------- Previous update was at 12:15 PM ----------
Hello,
I finally found the answer. It's not so pretty, but it works and is extremely fast (a few seconds) on a almost 2Mb file:
I'll try to explain what every command does:
- first awk sets the field delimiter to "^|" and deletes at most 3 new lines (I've discovered I have at most 4 lines of data in the 4th record = 3 new lines)
- the sed replaces the "%" with "_precent_" because I found that it breaks somehow the next awk command...
- the second awk command replaces all the "|" symbols beginning with the 4th field with "!" (I'm sure there will never be "!" in my last fields)
- the perl command replaces the last "!" with "|"
- the last sed replaces back the "%"
The result is a csv file with pipe as a delimiter wich I can use...
Maybe there is a more elegant solution but this works and is damn fast compared to the windows excel.
Hope this will help others too.
File is pipe delimited with 17 fields. We may get \n char (1 or more \n in one field or multi fileds) in data in any field.
Need to replace \n in data with space and not the Ture \n that is line separator.
I tried below awk command it did not work as expected.
awk '(NR-1)%2{$1=$1}1' RS=\|... (9 Replies)
HI All
Im trying to come up with an approach to finding a string, using a portion of that string to insert it on lines starting with the value "GOTO" appending to end of line after removing PT's ( See example below! )
EXAMPLE:
1. I would like to search for the line that starts with "TLAXIS/"... (7 Replies)
Hi
I've a string . And i need to replace set of characters with a single character
Means .. or . or ... and so on should be replaced with single % character
Irrespective of number of dots in between the characters , those should be replaced with single %
All the above strings should be... (3 Replies)
Hi Guys,
I wand find and replace all Extended ASCII Codes from all my log files.
My Log files:
/home/Kalr/PPool/Output
i have logs file in sub dir.
/home/Kalr/PPool/Output/X
/home/Kalr/PPool/Output/Y
/home/Kalr/PPool/Output/Z
My Abc.log file input:
Extended ASCII Codes :–
... (4 Replies)
Hi ,
I have problem on replace char on text file
#!/bin/bash
echo "Enter Third value : "
read a
sed '2 s/192.160.1.1/cut -d"." -f3/$a/g' tcpip.txt > a.txt
I want replace line 2 on tcpip.txt with value a that I input but it's not run
Please help me (2 Replies)
Hi!
I'm having trouble usind sed to remove the char ' from within a database's varchar register's sql.
For example, on the following sql:
INSERT INTO patrimonio_municipal.patrimonio_municipal_airc_tmp
Values('|Estação Elevatória|',|16723|,'|Grandes Reparações|',
'|2010-03-26... (3 Replies)
Hi,
How to replace any character in a file with a newline character using sed ..
Ex:
To replace ',' with newline
Input:
abcd,efgh,ijkl,mnop
Output:
abcd
efgh
ijkl
mnop
Thnx in advance.
Regards,
Sasidhar (5 Replies)
I know this has been asked previously on this forum...But I think I have a different scenario to present.
I ahve a file tht looks like this (note:there are control Z and other chars tht are not visible on line with anme bowers)
BB7118450 6004718 BIANCALANA =HEI
BZ5842819 ... (4 Replies)
Hi,
Can some one tell, how to replace ascii non printable TAB from the while to something, then later on replace it back to TAB.
Basciallz we do bulk data processing, our processin treats TAB as new field ,
So I thought we can replace it with something and later on revert it.
TIA (4 Replies)